stitch interferes with markdown formatting of code
See original GitHub issueIn this file index.md
the first code listing is parsed correctly by stitch, but the second, which is a verbatim code block that should be left to pandoc to handle, is mangled
# Title
Stitch
```{python3, echo=True}
a = 2
b = 3
print(a + b)
```
Verbatim listing
```python
def fn(a, b):
print("Hello")
return a + b
```
stitch index.md -o index.html
results in an index.html where the verbatim listing is converted to the following html:
<p>def fn(a, b): print("Hello") return a + b ```</p>
The expected HTML for that codeblock is
<div class="sourceCode"><pre class="sourceCode python"><code class="sourceCode python"><span class="kw">def</span> fn(a, b):
<span class="bu">print</span>(<span class="st">"Hello"</span>)
<span class="cf">return</span> a <span class="op">+</span> b</code></pre></div>
which is what you get when you run pandoc index.md -o index.html
.
Any ideas? I’m glad to go digging if this is not work in progress and in scope (and would welcome a pointer in the right direction).
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Developers - stitch interferes with markdown formatting of code -
stitch interferes with markdown formatting of code.
Read more >Basic Syntax - Markdown Guide
If the word or phrase you want to denote as code includes one or more backticks, you can escape it by enclosing the...
Read more >Spoilers don't support block formatting (and so don't format well)
2016: markdown still doesn't work, code blocks are hidden, <hr> still isn't. Oddly enough, if you go to the revisions page of this...
Read more >16 R Markdown and Publishing | R Cookbook, 2nd Edition
R Markdown is a package (as well as an ecosystem of tools) that allows us to add R code to a plain-text file...
Read more >Creating and highlighting code blocks - GitHub Docs
Share samples of code with fenced code blocks and enabling syntax highlighting. ... ```ruby require 'redcarpet' markdown = Redcarpet.new("Hello World!
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You’re correct about the intended behavior. Blocks like
should pass through to pandoc untouched. There’s a slight difficulty here, since by the time we get to the chunk execution / formatting, we’ve sent everything through pandocs internal AST, so the original source has been lost. I think attaching a sentinel value like
__stitch__=True
to code blocks likeshould do the trick.
I’ll have a bit more time to look at this in a couple days. Thanks for tracking it down so far!
As I understand Stitch tries to work with any code block that has at least one defined css class in attributes:
All these varians are the same for Stitch. In Knitty in order to automatically mass-disable code chunks I fixed
eval: True
global metadata.Actually you always can use
eval=False
to have static code samples. I wonder what happen to extra attrs when--to gfm
though…