Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Sourabh Verma
    @sourabhv

    Hi!

    I was following markdown-it-mark to create an extension that can identify ?@?@?@ as a delimiter, so ?@?@?@Foo?@?@?@ would be converted to <quesDelim>Foo</quesDelim>

    The problem is, state.pos starts at position 1 instead of 0. It works fine if I try to use @@@ as a delimiter. It skips ? completely. Also it looks like state.scanDelims scans only for same delimiters as the passed position. Is the ?@?@?@ delim even possible? (it's for internal use so I don't mind if this is against the markdown standard).

    Source with @@@ working: https://gist.github.com/sourabhv/1d7bebc74689c963356b6c330649cb10

    Vitaly Puzrin
    @puzrin
    https://github.com/markdown-it/markdown-it/blob/master/lib/rules_inline/text.js#L16-L38 seems you need to update text rule, to terminate on ?. I can't say right now why it's missed.
    I remembered, that text rules include all chars, which can be used for markup (in theory). Since use ? is bad idea, it's not used. But you can modify it for your needs.
    AT
    @llamamoray
    Hi, I recently created a ticket: markdown-it/markdown-it#518
    I wanted to try and diagnose this locally in the code
    is the easiest way to write a test? or can I run the playground locally?
    AT
    @llamamoray

    I've written this test, but even after upgrading linkify-it it still fails:

    should not terminate on slash underscore
    .
    https://www.riotinto.com/documents/_Iron%20Ore/Port_Handbook_Final_-_July_2016(2).pdf
    .
    <p><a href="https://www.riotinto.com/documents/_Iron%20Ore/Port_Handbook_Final_-_July_2016(2).pdf">https://www.riotinto.com/documents/_Iron%20Ore/Port_Handbook_Final_-_July_2016(2).pdf</a></p>
    .

    Any pointers to where in the library I should start looking into this?

    Daniel Weidner
    @dweidner
    Hi! Could someone help my understand, why String.charCodeAt() is used to search for strings? Is it to avoid encoding issues? I have created a small plugin to improve the generated markup of specific blockquotes and am currently using String.indexOf() to find my markers.
    Vitaly Puzrin
    @puzrin
    Operations with charcodes are usually faster, because more simple types used. But if you don't need to parse 10Mb/sec - don't worry :)
    Daniel Weidner
    @dweidner
    Ah, that was my second thought, that the iteration is more performant
    Thank you for your feedback
    David Luzar
    @dwelle

    Does anyone know of a quick markdown pre-parser that'd split a large document into chunks which can be rendered separately on their own (for perf reasons). I.e., something that's not as naive as splitting on newlines because that'd result in lists/codeBlocks being split midway. Could markdown-it be repurposed to do this?

    The idea is to lazy-render in chunks and render the chunks to DOM continually in separate frames. But also because of using a mark.js lib which takes hundreds of ms to highlight a large DOM tree, so the idea is to split the markdown document into chunks, and then render and highlight each, separately.

    David Luzar
    @dwelle
    I guess I can use markdown-it's parser and figure out what tokens it's safe to split the array on
    Vitaly Puzrin
    @puzrin
    References can be located anywhere. You can't render content right until refs collected. If you don't care about references, you can try to do quick-split: search empty lines + fences start. If fence found - skip lines until fence end.
    David Luzar
    @dwelle
    Yea, I'm thinking of doing a parse of whole doc (in web worker, so perf not an issue).. and splitting the tokens using some heuristic like block: true, level: 0 (if self-closing, else level: -1) or sth like that. Are there gonna be issues with this approach? If I pass same env object to all the split token arrays, there shouldn't be a problem?
    Vitaly Puzrin
    @puzrin
    I don't know. My idea was to collect line numbers, where content between can be independent, and store that separate. Then extract and parse appropriate slices on demand
    David Luzar
    @dwelle
    Forgot to get back in case anyone comes upon this --- the easiest way is to split the token stream on { level: 0, nesting: -1 } (nesting 0 pretty much happens only for hr so let's disregard it). WTBS, this approach works only if the document isn't one (or a few) huge level-0 elem, such as a list or codeBlock - in which case we'd need to split those big blocks up. Anyway, I ended up not doing this at all, so I'm not aware if this approach has any unintended consequences. Thanks @puzrin for your time.
    martijnn
    @martijnn
    Hi, quick question:
    Why is it that the bottom 4 examples don't get parsed properly in this example?
    Donny Yan
    @yanwenjun98
    Hello
    AlexanderSergan
    @AlexanderSergan
    Greetings! Firstly, thanks for maintaining such cool repo.
    Recently I encountered an issues with defining strong and em marks in different places of word:
    e.g. whole word renders correctly but partially it do not work. markdownIt demo
    Also, commonmark official demo renders this text differently: commonmark demo
    Is it a bug or desired behavior of implementation? Thanks
    Augusto Gonzalez
    @4uGuSt0o_twitter
    Hello
    I want to know how to remove rules from markdown-it
    AlexanderSergan
    @AlexanderSergan
    Hi, @4uGuSt0o_twitter! You can have a look at README.md: manage rules
    Augusto Gonzalez
    @4uGuSt0o_twitter
    Hello group
    David Luzar
    @dwelle
    What would be the easiest way to disallow inline images (i.e., if an inline image appears, make it block by wrapping it in p). I'm sure there would be cases where a block image wouldn't work, such as in tables, on inside links --- so perhaps force block-level image only if it's valid?
    Either way, can an inline rule such as image output block-level tokens at all?
    David Luzar
    @dwelle
    So I'm thinking of tokenizing as normal, and then wrapping applicable inline image tokens in paragraph_open/paragraph_close tokens..
    Vitaly Puzrin
    @puzrin
    In general, you need to rearrange tokens between parser and renderer. Injecting plugin to the end of core chain, for example. I can't give you more details, because technically your task is invalid and there are no iniversal principle to convert inline images to blocks (i mean html markup)
    David Luzar
    @dwelle

    yea, I ended up doing just that, and implemented two major cases where the image is separated from a paragraph by single newline ([ image, softbreak, ...inline-content ] and [ ...inline-content, softbreak, image ]). Doing this makes it non-CM-compliant, but we weren't CM-compliant to begin with (using softbreaks).

    For anyone interested, here's a partial implem:

    function createToken ( type = "inline", tag = "", nesting = 0, level = 0, children ) {
        const token = new md.core.State.prototype.Token( type, tag, nesting );
        token.level = level;
        if ( children ) token.children = children;
        return token;
    }
    
    let skipNext = false;
    state.tokens = state.tokens.reduce((acc, token, idx, tokens) => {
        if ( skipNext ) {
            skipNext = false;
            return acc;
        }
    
        if (
            token.type === "inline" &&
            tokens[idx - 1].type === "paragraph_open" &&
            tokens[idx + 1].type === "paragraph_close" &&
            token.children.length > 2
        ) {
    
            // case: [ image, softbreak, ...inline-content ]
            if (
                token.children[0].type === "image" &&
                token.children[1].type === "softbreak"
            ) {
                skipNext = true;
    
                const imageToken = token.children[0];
                token.children = token.children.slice(2);
                return acc.slice(0, -1).concat([
                    createToken("paragraph_open", "p", 1, token.level),
                    createToken("inline", "", 0, 1, [ imageToken ]),
                    createToken("paragraph_close", "p", -1, token.level),
                    acc[acc.length - 1],
                    token,
                    tokens[idx + 1],
                ]);
            // case: [ ...inline-content, softbreak, image ]
            } else if (
                token.children[token.children.length - 1].type === "image" &&
                token.children[token.children.length - 2].type === "softbreak"
            ) {
                skipNext = true;
    
                const imageToken = token.children[token.children.length - 1];
                token.children = token.children.slice(0, -2);
                return acc.concat([
                    token,
                    tokens[idx + 1],
                    createToken("paragraph_open", "p", 1, token.level),
                    createToken("inline", "", 0, 1, [ imageToken ]),
                    createToken("paragraph_close", "p", -1, token.level)
                ]);
            }
        }
    
        acc.push(token);
        return acc;
    }, [] );
    Vincent B.
    @evilz
    Hi all
    I'm looking for a very simple block plugin sample of code
    My need is simple and dirty
    I need to find all text after ^Note: and put this in aside element
    AbhishekChugh
    @AbhishekChugh
    Hi all!
    I was wondering if there is any angular2+ support (directives, modules, pipes etc.) available for use. Any pointers, suggestions, snippets will be highly appreciated.
    Thanks!
    Dana
    @dmxt
    I discovered a mistake on this project's Travis CI and it's the very first command mentioned lol
    What is the best way to approach this for correction?
    Ankur Narkhede
    @smartankur4u
    Hello guys! I am using markdown-it. I had a few queries.
    Ankur Narkhede
    @smartankur4u
    markdown-it doesn't play with tabs and spaces while parsing. If a markdown with 4 tab size is parsed with markdown-it and displayed over any other browser with different tab size, the alignment of the text will be different.
    Will it be fine to first convert tabs to appropriate number of spaces before parsing it? So as the desired view is displayed in every device irrespective of the tab size?
    Ankur Narkhede
    @smartankur4u
    for example, you can try writing any text using mixed tabs and spaces in the editor, copy it to markdown-it demo and view the result.

    I came across the ParseDown PHP package on Packagist. It did converted everything to spaces and the alignment was proper.

    https://parsedown.org/demo

    Vitaly Puzrin
    @puzrin
    As far as i remember, markdowm-it keeps tabs as is, but it's always good idea to replace those with spaces for better control. I would suggest also to read commonmark spec, if you have any questions about markup https://spec.commonmark.org/
    Ankur Narkhede
    @smartankur4u
    @puzrin As per I went through the commonmark spec (https://spec.commonmark.org/0.29/#tabs), it suggests only converting the leading tabs in each line to spaces, not the internal ones.
    As far as I experimented, the internal tabs are the ones that cause issues in alignment.
    Ankur Narkhede
    @smartankur4u

    I have been using the marked NPM package for parsing markdown. I found the issue that they are converting the tab character to 4 spaces every time, irrespective of the characters included in the current tab block. This causes disruption in the alignment of parsed markdown.

    Because of it, I had to write a custom code to convert tabs to appropriate number of spaces before parsing with marked NPM.

    @puzrin Can you please go through the issue: markedjs/marked#1559
    and let me know your views.
    Vitaly Puzrin
    @puzrin
    Sorry, no time to review other packages. I can only fix bugs in markdown-it, if it diverges from spec.
    Ankur Narkhede
    @smartankur4u
    @puzrin, not asking to review other packages.
    Can you please let me know if any changes are required in markdown-it regarding tabs and spaces.
    Ankur Narkhede
    @smartankur4u

    @puzrin , can I get your views over this, so that I can contribute?

    @puzrin, not asking to review other packages.
    Can you please let me know if any changes are required in markdown-it regarding tabs and spaces.