Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

footnote bug? #92

Closed
maelle opened this issue Feb 23, 2023 · 8 comments
Closed

footnote bug? #92

maelle opened this issue Feb 23, 2023 · 8 comments
Labels
bug Something isn't working

Comments

@maelle
Copy link
Member

maelle commented Feb 23, 2023

lines <- c("lala[^1]", "", "[^1]: pof")

temp_file <- withr::local_tempfile()
brio::write_lines(lines, temp_file)

tinkr::yarn$new(temp_file)$write(temp_file)

brio::read_lines(temp_file)
#> [1] "lala[^1][^1]" ""             "[^1]: pof"    ""             ""            
#> [6] ""

# second one
lines <- c("lala[^1] blabla", "", "[^1]: pof")

temp_file <- withr::local_tempfile()
brio::write_lines(lines, temp_file)

tinkr::yarn$new(temp_file)$write(temp_file)

brio::read_lines(temp_file)
#> [1] "lala[^1][^1] blabla" ""                    "[^1]: pof"          
#> [4] ""                    ""                    ""

Created on 2023-02-23 with reprex v2.0.2

@zkamvar
Copy link
Member

zkamvar commented Mar 17, 2023

OMG why didn't I see this!?

@zkamvar zkamvar added the bug Something isn't working label Mar 17, 2023
@maelle
Copy link
Member Author

maelle commented Mar 21, 2023

Maybe because you write clear text that doesn't need footnotes?!

@zkamvar
Copy link
Member

zkamvar commented Mar 22, 2023

Maybe because you write clear text that doesn't need footnotes?!

*wheezing*

Funny enough, the most recent update of {commonmark} has "footnotes" support, but it's a bit strange:

txt <- c("a statement[^1][^2]\n", "[^1]: this is true", "[^2]: this is false")
commonmark::markdown_xml(txt, footnotes = TRUE) |> writeLines()
#> <?xml version="1.0" encoding="UTF-8"?>
#> <!DOCTYPE document SYSTEM "CommonMark.dtd">
#> <document xmlns="http://commonmark.org/xml/1.0">
#>   <paragraph>
#>     <text xml:space="preserve">a statement</text>
#>     <<unknown> />
#>     <<unknown> />
#>   </paragraph>
#>   <<unknown>>
#>     <paragraph>
#>       <text xml:space="preserve">this is true</text>
#>     </paragraph>
#>   </<unknown>>
#>   <<unknown>>
#>     <paragraph>
#>       <text xml:space="preserve">this is false</text>
#>     </paragraph>
#>   </<unknown>>
#> </document>

Created on 2023-03-22 with reprex v2.0.2

@zkamvar
Copy link
Member

zkamvar commented Mar 28, 2023

OH I think I know what's going on! {tinkr} sees this footnote as a relative link:

lines <- c("[thing] lala[^1] blabla", "", "[thing]: what", "[^1]: pof")

temp_file <- withr::local_tempfile()
brio::write_lines(lines, temp_file)

tinkr::yarn$new(temp_file)$show()
#> [thing][thing] lala[^1][^1] blabla
#> 
#> [thing]: what
#> [^1]: pof

Created on 2023-03-28 with reprex v2.0.2

@zkamvar
Copy link
Member

zkamvar commented Mar 28, 2023

The happy thing is that we can fix this with a little XSLT!

@zkamvar
Copy link
Member

zkamvar commented Mar 28, 2023

For reference, the fix for this issue is in beb8277

@zkamvar
Copy link
Member

zkamvar commented Mar 28, 2023

this has been fixed in #94

@zkamvar zkamvar closed this as completed Mar 28, 2023
@maelle
Copy link
Member Author

maelle commented Mar 30, 2023

thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants