Comments (5)
Thanks for the analysis :)
(I found this in a table with more than 3 consecutive -
's, but simplified the table for reporting, and then have related it to another isssue #131 unexpectedly)
from mistletoe.
As mistletoe has the ambition to support custom tokens, it would be nice if it also had a mechanism to customize which tokens are allowed to interrupt a paragraph. As you point out @pbodnar , this is currently hard coded in Paragraph.read()
. With such a mechanism in place, it should be straightforward to enable the desired behavior for tables.
I have some ideas about how to do this, so I'll try and make a PR out of them.
from mistletoe.
@minaminao, thanks for the report. After some analysis, I would consider this a change request which could be stated like this:
Enable tables which interrupt a paragraph (like GFM does)
Let me explain why. The following, slightly modified markdown from your example works as expected in mistletoe:
A:
|a|b|
|---|---|
|a|b|
I. e. when there is a blank line between the blocks, table is parsed correctly. Also note the 3 consecutive dashes used in the separator cells - this is covered by #131, so I won't dive into this here.
The GFM spec, being an extension of the CommonMark spec, clearly states when a given token type might "interrupt a paragraph". Unfortunately, authors of GitHub somewhat forgot to specify this for their extension token type table. Yet, it is evident from their implementation of markdown here that they do support this interruption.
Therefore we could try as well, but it won't be a trivial change, because before adding corresponding Table.start()
check into the lines iteration inside Paragraph.read()
, we need to extend existing Table.start()
check (it is a simple return '|' in line
right now) and also related code. This change will imply some performance penalty, so we need to be cautious. Also for backwards compatibility reasons, we should probably make this an optional (switchable) feature of mistletoe.
To conclude, while the requested change makes sense, I would possibly not put it on the todo list for the very next mistletoe version. But I can imagine trying to implement this together with the other tables related issues...
CC to @anderskaplan, our top contributor, who maybe can also give some thoughts on this? :)
from mistletoe.
@anderskaplan, that looks promising - having it implemented in a more generic way, not just for Table
, would be great. :)
from mistletoe.
Created two PR's: one "infrastructure" fix (#186) and a draft PR for the new mechanism + table change (#187).
from mistletoe.
Related Issues (20)
- IndexError on malformed markdown tables HOT 1
- Emphasis around link ignored when followed by a special punctuation character HOT 1
- Don't convert the quotes HOT 3
- Contrib sub-package is missing in the mistletoe 1.0.0 PyPI version HOT 3
- Question how to modify ast and write back out as markdown HOT 4
- Do not escape double or single quotes by default HOT 1
- Use strict PascalCase for class names HOT 3
- Renderer for Natural Docs HOT 6
- How to add a custom token inside a block token? HOT 1
- How to add a custom token inside a block token? HOT 3
- make output markdown keep original indentation of the 1st line in a list item
- parse-render loop creates newline HOT 3
- How to use extension tokens for parsing? HOT 4
- Render Heading to markdown: ValueError: list.remove(x): x not in list HOT 2
- `block_token.List.start` is both a classmethod and attribute HOT 1
- BaseRenderer.render_line_break does not work without override HOT 1
- Delete a Document node. Recommended way? HOT 4
- `MarkdownRenderer` is not concurrent safe HOT 4
- MarkdownRenderer should emit extra newline after list HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mistletoe.