question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

stitch interferes with markdown formatting of code

See original GitHub issue

In 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(&quot;Hello&quot;) 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">&quot;Hello&quot;</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:open
  • Created 7 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
TomAugspurgercommented, Feb 28, 2017

You’re correct about the intended behavior. Blocks like

```python
def f():
    ...
```

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 like

```{lang}
```

should 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!

0reactions
kiwi0fruitcommented, Dec 22, 2018

As I understand Stitch tries to work with any code block that has at least one defined css class in attributes:

```python
# do
```

```{.python}
# do
```

```{python}
# do
```

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…

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found