Implement escaping in src (org only) and example blocks

inside src example blocks lines starting with `\s*,` are escaped - i.e. org
mode will not try to parse them as e.g. a headline. We don't want to render the
escape commata to html so let's take them out - and put them back in before
rendering to org. Doing it this way allows us to render them correctly even
when the input did not include them.

see https://orgmode.org/manual/Literal-Examples.html#Literal-Examples
This commit is contained in:
Niklas Fasching 2020-04-16 15:49:32 +02:00
parent cbf1b8c38c
commit d417c2a6dd
5 changed files with 65 additions and 2 deletions

View file

@ -96,6 +96,24 @@ paragraphs
</li>
</ul>
</blockquote>
<div class="src src-org">
<div class="highlight">
<pre>
#+BEGIN_SRC bash
echo src (with language org) and example blocks support escaping using commata
#+END_SRC
,* I am not a real headline - commata escape characters aren&#39;t renderered
</pre>
</div>
</div>
<pre class="example">
#+BEGIN_SRC bash
echo src (with language org) and example blocks support escaping using commata
#+END_SRC
,* I am not a real headline - commata escape characters aren&#39;t renderered
</pre>
<script>
console.log("Hello World!")
</script>

View file

@ -51,6 +51,23 @@ blocks like the quote block parse their content and can contain
it can be made visible using css (e.g. =white-space: pre=).
#+END_QUOTE
#+BEGIN_SRC org
,#+BEGIN_SRC bash
echo src (with language org) and example blocks support escaping using commata
,#+END_SRC
,,* I am not a real headline - commata escape characters aren't renderered
#+END_SRC
#+BEGIN_EXAMPLE
,#+BEGIN_SRC bash
echo src (with language org) and example blocks support escaping using commata
,#+END_SRC
,,* I am not a real headline - commata escape characters aren't renderered
#+END_EXAMPLE
#+BEGIN_EXPORT html
<script>
console.log("Hello World!")

View file

@ -51,6 +51,23 @@ blocks like the quote block parse their content and can contain
it can be made visible using css (e.g. =white-space: pre=).
#+END_QUOTE
#+BEGIN_SRC org
,#+BEGIN_SRC bash
echo src (with language org) and example blocks support escaping using commata
,#+END_SRC
,,* I am not a real headline - commata escape characters aren't renderered
#+END_SRC
#+BEGIN_EXAMPLE
,#+BEGIN_SRC bash
echo src (with language org) and example blocks support escaping using commata
,#+END_SRC
,,* I am not a real headline - commata escape characters aren't renderered
#+END_EXAMPLE
#+BEGIN_EXPORT html
<script>
console.log("Hello World!")
@ -80,7 +97,7 @@ this unindented line is outside of the list item
#+BEGIN_QUOTE
#+BEGIN_EXAMPLE
#+END_QUOTE
,#+END_QUOTE
#+END_EXAMPLE
#+END_QUOTE