Internal link starting with a slash - emacs

I have an org mode document containing headers that start with a slash (for italics), such as
* /This/ is my header
how can I create an internal link to this header? Since it starts with a slash, org thinks it looks like a file name.
(org mode 9.4.6, emacs 27.2)

I found out the solution. In the link, add an asterisk before the header name:
[[*/This/ is my header]]

Related

Failing to render a header on GitHub

Here's my README.md in a GitHub repo:
###This is a Header
This is not a Header
Both lines render as plain text. The first one should render as a Header and I remember it did previously.
I have no idea what's wrong with my browsers (Chrome on macOS), I've tried Firefox and Opera but nothing helps.
it's not a problem of your browser. I found the same "bug", too.
GitHub just update their markdown renderer to CommonMark: https://github.com/blog/2333-a-formal-spec-for-github-flavored-markdown
and CommonMark requires that a space character be between the # characters and the title: ### Header
###This is not a Header
### This is a Header
Though most of my MarkDown editor (Typora, MacDown) render them Header:
Put a space after #. It seems that's necessary.
Per the new specification, for the ATX-style headings (emphasis mine):
The opening sequence of # characters must be followed by a space or by the end of line.
...
At least one space is required between the # characters and the
heading’s contents, unless the heading is empty. Note that many
implementations currently do not require the space. However, the space
was required by the original ATX
implementation...

How do I tell org-mode to disable headings in verbatim text?

How do I make org mode not interpret a line that begins with an asterisk as a headline? I have some verbatim text in my org mode document. Some of the lines begin with an asterisk. Org mode interprets these lines as headlines. I don't want that.
Here is the text with some context:
* 20160721 Headline for July 21, 2016
I created a git repository for rfc-tools. It's in
~/Documents/rfc-tools.
Renamed grep-rfc-index.sh to search-rfc-index.sh because it searches.
That it uses grep is irrelevant.
Wrote a README.md for the project. Here it is:
#+BEGIN_SRC text
----- BEGIN QUOTED TEXT -----
This is the README.md for rfc-tools, a collection of programs for
processing IETF RFCs.
* fetch-rfcs-by-title.sh downloads into the current directory the RFCs
whose titles contain the string given on the command line. Uses an
rfc-index file in the current directory. Prefers the PDF version of
RFCs but will obtain the text version if the PDF is not available.
* fetch-sip-rfcs.sh downloads RFCs that contain "Session Initiation"
in their titles into the current directory.
* search-rfc-index.sh searches an rfc-index file in the current
directory for the string given on the command line. The string can
contain spaces.
* join-titles.awk turns the contents of an rfc-index file into a
series of long lines. Each line begins with the RFC number, then a
space, then the rest of the entry from the rfc-index.
----- END QUOTED TEXT -----
#+END_SRC
I want the lines between "----- BEGIN QUOTED TEXT -----" and "----- END QUOTED TEXT -----" to be plain text and subordinate to the headline "20160721 Headline for July 21, 2016". Org mode interprets all lines that begin with an asterisk as top-level headlines.
By the way, the verbatim text is Markdown. I hope that doesn't matter.
worked for me:
#+BEGIN_SRC markdown
Try wrapping your text in one of the various special block tags. For example you could try putting your text inside these tags:
#+BEGIN_SRC text
...
#+END_SRC
Here is a screenshot of how the formatting turns out on my Emacs:
If that doesn't meet your needs, you could try:
#+BEGIN_EXAMPLE
...
#+END_EXAMPLE
Which will render everything inside the tags without markup and in a monospace font.
If that doesn't work either, you could try one of the other kinds of tags listed here.
Escape the * with a comma like this,*
Probably if you type C-c ' to enter a special edit and then exit, org will do that for you.
I think the answer is "You can't do that". I found a way to work around the problem using drawers. The org-mode manual explains that a drawer is a place to put text that you don't want to see all of the time.
A StackExchange user had a question about
getting a custom org drawer to open/close. It seems that for older versions of org-mode, you must tell org-mode the names of your drawers. E.g. If you have a drawer named "COMMANDS"
:COMMANDS:
ls
cat
grep
:END:
you must tell org-mode the name of the drawer using the +DRAWERS keyword:
#+DRAWERS COMMAND
and restart org-mode.
I found a solution:
Escape Character
You may sometimes want to write text that looks like Org syntax, but should really read as plain text. Org may use a specific escape character in some situations, i.e., a backslash in macros (see Macro Replacement) and links (see Link Format), or a comma in source and example blocks (see Literal Examples). In the general case, however, we suggest to use the zero width space. You can insert one with any of the following:
C-x 8 zero width space
C-x 8 200B
For example, in order to write ‘[[1,2]]’ as-is in your document, you may write instead
[X[1,2]]
where ‘X’ denotes the zero width space character.
How to remove zero width space:
sed -i "s/$(echo -ne '\u200b')//g" abc.txt

How to escape the (hash) # sign in a GitHub markdown header? (backslash is not working)

I have the following code on a README.md file on GitHub, where I am trying to display the hash sign on a header (I am trying to escape it using the \ symbol) like so:
### C\#
* [Beginning Game Programming with C#](https://www.coursera.org/course/gameprogramming)
However it renders like so:
I obviously want the hash sign to appear on the header, and I also tried to use a double backslash, but it didn't work. How do I get the pound sign to appear?
EDIT: the linked question deals with GitHub links, my question is to do with headers on a .md file.
You could try and add a matching '#', followed by one extra '#':
### C# #
As in this answer you can insert an invisible character before the octothorpe, such as ​.
Add an extra space after ### C\#. See the demo.

How to get rid of Org-mode link translation?

I write articles with org-mode, It works very well. But I found a very annoying problem.
I post my article to some forum, also I have a lot of pics to post.
I use IMG code to post the pictures.
eg. [IMG]http://abc.com/a.jpg[/IMG]
I export my org file to ascii or html or anything else formant, Org-mode always make "http" special. It export like this:
[IMG][http://abc.com/a.jpg[/IMG]]
between "http", There are always a pair of "[". Every time I have to remove this myself.
I wish Org-mode do not handle http string.
Any idea?
Org mode actually parses that particular markup poorly (with the square brackets). If your image links are on a separate line, for example between paragraphs, you can use some markup to disable org formatting:
#+BEGIN_EXAMPLE
[IMG]http://abc.com/a.jpg[/IMG]
#+END_EXAMPLE
A shorthand for this is simply to start the line with a colon followed by a space:
: [IMG]http://abc.com/a.jpg[/IMG]

Wikipedia (MediaWiki) URI encoding scheme

How do Wikipedia (or MediaWiki in general) encode page titles in URIs? It's not normal URI encoding, since spaces are replaced with underscores and double quotes are not encoded and things like that.
http://en.wikipedia.org/wiki/Wikipedia:Naming_conventions_%28technical_restrictions%29 - here you've got some kind of description of what their engine enforces on article names.
They should have something like this in their LocalSettings.php:
$wgArticlePath = '/wiki/$1';
and proper server URI rewrites configuration - they seem to be using Apache (HTTP header), so it's probably mod_rewrite. http://www.mediawiki.org/wiki/Manual:Short_URL
You can also refer to the index.php file for an article on Wikipedia like this: http://en.wikipedia.org/w/index.php?title=Foo%20bar and get redirected by the engine to http://en.wikipedia.org/wiki/Foo_bar. Behind the scenes mod_rewrite translates it into /index.php?title=Foo_bar. For the MediaWiki engine it's the same as if you visited http://en.wikipedia.org/w/index.php?title=Foo_bar - this page doesn't redirect you.
The process is quite complex and isn't exactly pretty. You need to look at the Title class found in includes/Title.php. You should start with the newFromText method, but the bulk of the logic is in the secureAndSplit method.
Note that (as ever with MediaWiki) the code is not decoupled in the slightest. If you want to replicate it, you'll need to extract the logic rather than simply re-using the class.
The logic looks something like this:
Decode character references (e.g. é)
Convert spaces to underscores
Check whether the title is a reference to a namespace or interwiki
Remove hash fragments (e.g. Apple#Name
Remove forbidden characters
Forbid subdirectory links (e.g. ../directory/page)
Forbid triple tilde sequences (~~~) (for some reason)
Limit the size to 255 bytes
Capitalise the first letter
Furthermore, I believe I'm right in saying that quotation marks don't need to be encoded by the original user -- browsers can handle them transparently.
I hope that helps!