Underline in org-mode Literal Example - emacs

According to the explanation on Literal Example, literal examples should not be subjected to mark-up. But Is there any way to use any mark-up in literal example?
For example, consider the following literal example snippet.
#+BEGIN_EXAMPLE
Enter the city you're from: Chicago
#+END_EXAMPLE
I'd like to put an underline at the word Chicago because I want to emphasize that the word Chicago is typed by user. How can I do that?

If all you want is the example to be typeset in the example fashion, you can probably use emphasis markup, at least for the lines that require mark-up. That would be
=Enter the city you're from:= _Chicago_
I don't think what you request is at all possible, possibly because such blocks seem to be by design not subject to mark-up.
For language-specific mark-up, use source code blocks (#+begin_src), maybe you can get nicely marked-up blocks using org-mode code blocks (#+begin_src org) (though I didn't manage to get "what it looks like" to be exported, I guess that's what in-line org is for).

Related

How to give name to quotation blocks in emacs org-mode

I have created a quote with the following syntax
#+BEGIN_QUOTE
My quote....
#+END_QUOTE
The problem is that in the collapsed view (when only titles and top-level outlines are shown), I see
#+BEGIN_QUOTE...
Which does not properly inform of the content of the quote. Is there a way to give a name or label to the quote so that I can see something like the below instead:
Quote from Jack...
Thank you
You can give names to blocks, whether those blocks are quote blocks, source blocks or any other kind (you can also give names to tables). The advantage is that each quote block can have its own name (in contrast to tags, which apply to a headline, so if you have more than one block in a section, the tag will not disambiguate them). On the other hand, names are more intrusive and to some extent defeat the purpose of collapsing: they are always there whether the block is collapsed or not; tags are more discreet:
* foo :quotes:
#+name: kennedy
#+begin_quote
Do not ask what your country can do for you...
#+end_quote
#+name: lincoln
#+begin_quote
Four score and seven years ago...
#+end_quote
Which one you want to use is up to you (and "both" is also a possibility).
Use tags
From the org manual:
An excellent way to implement labels and contexts for cross-correlating information is to assign tags to headlines

Superscript within code block in Github Markdown

The <sup></sup> tag is used for superscripts. Creating a code block is done with backticks. The issue I have is when I try to create a superscript within a code block, it prints out the <sup></sup> tag instead of formatting the text between the tag.
How do I have superscript text formatted correctly when it's between backticks?
Post solution edit
Desired output:
A2 instead of A<sup>2</sup>
This is not possible unless you use raw HTML.
The rules specifically state:
With a code span, ampersands and angle brackets are encoded as HTML entities automatically, which makes it easy to include example HTML tags.
In other words, it is not possible to use HTML to format text in a code span. In fact, a code span is plain, unformatted text. Having any of that text appear as a superscript would mean it is not plain, unformatted text. Thus, this is not possible by design.
However, the rules also state:
Markdown is not a replacement for HTML, or even close to it. Its
syntax is very small, corresponding only to a very small subset of
HTML tags. The idea is not to create a syntax that makes it easier
to insert HTML tags. In my opinion, HTML tags are already easy to
insert. The idea for Markdown is to make it easy to read, write, and
edit prose. HTML is a publishing format; Markdown is a writing
format. Thus, Markdown's formatting syntax only addresses issues that
can be conveyed in plain text.
For any markup that is not covered by Markdown's syntax, you simply
use HTML itself. ...
So, if you really need some text in a code span to be in superscript, then use raw HTML for the entire span (be sure to escape things manually as required):
<code>A code span with <sup>superscript</sup> text and escaped characters: "<&>".</code>
Which renders as:
A code span with superscript text and escaped characters: "<&>".
This is expected behaviour:
Markdown wraps a code block in both <pre> and <code> tags.
You can use Unicode superscript and subscript characters within code blocks:
class SomeClass¹ {
}
Inputting these characters will depend on your operating system and configuration. I like to use compose key sequences on my Linux machines. As a last resort you should be able to copy and paste them from something like the Wikipedia page mentioned above.
¹Some interesting footnote, e.g. referencing MDN on <pre> and <code> tags.
If you're luck, the characters you want to superscript (or subscript) may have dedicated codepoints in Unicode. These will work inside codeblocks, as demonstrated in your question, where you include A² in backticks. Eg:
Water (chemical formula H₂O) is transparent, tasteless and odourless.
I've listed out the super and subscript Unicode characters in this Gist. You should be able to copy and paste any you need from there.

Superscript in markdown (Github flavored)?

Following this lead, I tried this in a Github README.md:
<span style="vertical-align: baseline; position: relative;top: -0.5em;>text in superscript</span>
Does not work, the text appears as normal. Help?
Use the <sup></sup>tag (<sub></sub> is the equivalent for subscripts). See this gist for an example.
You have a few options for this. The answer depends on exactly what you're trying to do, how readable you want the content to be when viewed as Markdown and where your content will be rendered:
HTML Tags
As others have said, <sup> and <sub> tags work well for arbitrary text. Embedding HTML in a Markdown document like this is well supported so this approach should work with most tools that render Markdown.
Personally, I find HTML impairs the readable of Markdown somewhat, when working with it "bare" (eg. in a text editor) but small tags like this aren't too bad.
LaTeX (New!)
As of May 2022, GitHub supports embedding LaTeX expressions in Markdown docs directly. This gives us new way to render arbitrary text as superscript or subscript in GitHub flavoured Markdown, and it works quite well.
LaTeX expressions are delineated by $$ for blocks or $ for inline expressions. In LaTeX you indicate superscript with the ^ and subscript with _. Curly braces ({ and }) can be used to group characters. You also need to escape spaces with a backslash. The GitHub implementation uses MathJax so see their docs for what else is possible.
You can use super or subscript for mathematical expressions that require it, eg:
$$e^{-\frac{t}{RC}}$$
Which renders as..
Or render arbitrary text as super or subscript inline, eg:
And so it was indeed: she was now only $_{ten\ inches\ high}$, and her face brightened up at the thought that she was now the right size for going through the little door into that lovely garden.
Which renders as..
I've put a few other examples here in a Gist.
Unicode
If the superscript (or subscript) you need is of a mathematical nature, Unicode may well have you covered.
I've compiled a list of all the Unicode super and subscript characters I could identify in this gist. Some of the more common/useful ones are:
⁰ SUPERSCRIPT ZERO (U+2070)
¹ SUPERSCRIPT ONE (U+00B9)
² SUPERSCRIPT TWO (U+00B2)
³ SUPERSCRIPT THREE (U+00B3)
ⁿ SUPERSCRIPT LATIN SMALL LETTER N (U+207F)
People also often reach for <sup> and <sub> tags in an attempt to render specific symbols like these:
™ TRADE MARK SIGN (U+2122)
® REGISTERED SIGN (U+00AE)
℠ SERVICE MARK (U+2120)
Assuming your editor supports Unicode, you can copy and paste the characters above directly into your document or find them in your systems emoji and symbols picker.
On MacOS, simultaneously press the Command ⌘ + Control + Space keys to open the emoji picker. You can browse or search, or click the small icon in the top right to open the more advanced Character Viewer.
On Windows, you can a emoji and symbol picker by pressing ⊞ Windows + ..
Alternatively, if you're putting these characters in an HTML document, you could use the hex values above in an HTML character escape. Eg, ² instead of ². This works with GitHub (and should work anywhere else your Markdown is rendered to HTML) but is less readable when presented as raw text.
Images
If your requirements are especially unusual, you can always just inline an image. The GitHub supported syntax is:
![Alt text goes here, if you'd like](path/to/image.png)
You can use a full path (eg. starting with https:// or http://) but it's often easier to use a relative path, which will load the image from the repo, relative to the Markdown document.
If you happen to know LaTeX (or want to learn it) you could do just about any text manipulation imaginable and render it to an image. Sites like Quicklatex make this quite easy. Of course, if you know your document will be rendered on GitHub, you can use the new (2022) embedded LaTeX syntax discussed earlier)
Comments about previous answers
The universal solution is using the HTML tag <sup>, as suggested in the main answer.
However, the idea behind Markdown is precisely to avoid the use of such tags:
The document should look nice as plain text, not only when rendered.
Another answer proposes using Unicode characters, which makes the document look nice as a plain text document but could reduce compatibility.
Finally, I would like to remember the simplest solution for some documents: the character ^.
Some Markdown implementation (e.g. MacDown in macOS) interprets the caret as an instruction for superscript.
Ex.
Sin^2 + Cos^2 = 1
Clearly, Stack Overflow does not interpret the caret as a superscript instruction. However, the text is comprehensible, and this is what really matters when using Markdown.
If you only need superscript numbers, you can use pure Unicode. It provides all numbers plus several additional characters as superscripts:
x⁰¹²³⁴⁵⁶⁷⁸⁹⁺⁻⁼⁽⁾ⁿⁱ
However, it might be that the chosen font does not support them, so be sure to check the rendered output.
In fact, there are even quite a few superscript letters, however, their intended use might not be for superscript, and font support might be even worse. Use your own judgement.

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]

Matching unknown # of occurrences on a page using perl?

i am parsing an html page, let's say this page lists all players in a football team and those who are seniors will be bolded. I can't parse the file line by line and look for the strong tag because in my real example the pattern is much more complex and span multiple lines.
Something like this:
<strong>Senior:</strong> John Smith
Junior: Joe Smith
<strong>Senior:</strong> Mike Johnson
and so on. How do I write a perl regex to get the names of all seniors?
Thanks
The reason you're having difficulty writing a regex to do this is because it's the wrong tool for the job. You should use a real HTML parser like HTML::Parser, HTML::TokeParser, or HTML::TreeBuilder.
I can't give a specific example because I doubt that's exactly what your HTML looks like. Your sample appears to be missing some punctuation or additional tags.
You don't have to parse a file line by line -- you can read in the entire file at once, if it's small, or you can parse it paragraph by paragraph, using whatever separator you like.
The two magic things you need to do this are 1. set the "line separator" variable, $/ (see perldoc perlvar), to be something else than a newline, and 2. enable multi-line regular expression matching with the /s modifier (see perldoc perlre).
Alternatively, you should use an HTML parser, which is what you would have to do if you are attempting to find things like nested tags.
You have to provide a specific example.
Perl regular expressions can be occasionally used for HTML parsing, but only when you know specifically how the page looks like and that it's not too complex.
If you don't know exactly or it is too complex, use the parsers that cjm links.
It's not clear from your example how the end of the senior name is going to be determined, but something like this:
my #seniors = $filecontents =~ m!<strong>Senior:</strong>\s*([^<]+)!g;