Closed krlmlr closed 6 months ago
For whatever reason it seems like the md1
example is missing a md_block_p
around the bullet's text, while the md_block_p
exists for both of the bullets in md2
. I would guess that this is an upstream issue with md4c.
parse_md(md1)
#> md_block_doc [flags: "MD_DIALECT_COMMONMARK"]
#> ├── md_block_h [level: 1]
#> │ └── md_text_normal - "Header 1"
#> ├── md_block_ul [tight: 1, mark: "-"]
#> │ └── md_block_li
#> │ ├── md_span_code
#> │ │ └── md_text_code - "my_fun()"
#> │ ├── md_text_normal - " replaces "
#> │ ├── md_span_code
#> │ │ └── md_text_code - "my_other_fun()"
#> │ └── md_text_normal - " (#123)."
#> └── md_block_h [level: 1]
#> └── md_text_normal - "Header 2"
parse_md(md2)
#> md_block_doc [flags: "MD_DIALECT_COMMONMARK"]
#> ├── md_block_h [level: 1]
#> │ └── md_text_normal - "Header 1"
#> ├── md_block_ul [tight: 0, mark: "-"]
#> │ ├── md_block_li
#> │ │ └── md_block_p
#> │ │ ├── md_span_code
#> │ │ │ └── md_text_code - "my_fun()"
#> │ │ ├── md_text_normal - " replaces "
#> │ │ ├── md_span_code
#> │ │ │ └── md_text_code - "my_other_fun()"
#> │ │ └── md_text_normal - " (#123)."
#> │ └── md_block_li
#> │ └── md_block_p
#> │ ├── md_span_code
#> │ │ └── md_text_code - "my_fun()"
#> │ ├── md_text_normal - " replaces "
#> │ ├── md_span_code
#> │ │ └── md_text_code - "my_other_fun()"
#> │ └── md_text_normal - " (#123)."
#> └── md_block_h [level: 1]
#> └── md_text_normal - "Header 2"
In all fairness the code for assembling a md_block_li
is a bit convoluted so there may be a way to fix it at that level as well.
I think the paragraph only gets added if there is space between two bullet points. Simpler reprex:
library(md4r)
md <- "
# Header 1
- `my_fun()` replaces `my_other_fun()` (#123).
- `my_fun()` replaces `my_other_fun()` (#123).
"
writeLines(to_md(parse_md(md)))
#> # Header 1
#>
#> - `my_fun()`
#> replaces
#> `my_other_fun()`
#> (#123).
#> - `my_fun()`
#> replaces
#> `my_other_fun()`
#> (#123).
Created on 2024-03-03 with reprex v2.1.0
Even simpler:
library(md4r)
md <- "
- `my_fun()` replaces
- `my_fun()` replaces
"
writeLines(to_md(parse_md(md)))
#> - `my_fun()`
#> replaces
#> - `my_fun()`
#> replaces
Created on 2024-03-03 with reprex v2.1.0
Closing in favor of #8.
I wonder what causes the difference in the roundtrip between the two examples.
Created on 2024-02-18 with reprex v2.1.0