patrickdavey / vimwiki_markdown

A gem to use for converting vimwiki markdown files to html.
MIT License
144 stars 16 forks source link

When file contains danish letters æøå the conversion won't happen. #44

Closed Poetastrophe closed 1 year ago

Poetastrophe commented 2 years ago

When file contains danish letters æøå the conversion won't happen.

To reproduce:

  1. make a markdown file in your vimwiki folder (here I called it test2.md)
  2. When I write the following and run Vimwiki2HTML from nvim
  3. ø
  4. I get the following error:
    Vimwiki: '/home/chris/.local/share/gem/ruby/3.1.0/gems/vimwiki_markdown-0.8.2/lib/vimwiki_markdown/wiki_body.rb:52:in `gsub!'': invalid byte sequence in US-ASC
    II (ArgumentError)
        from /home/chris/.local/share/gem/ruby/3.1.0/gems/vimwiki_markdown-0.8.2/lib/vimwiki_markdown/wiki_body.rb:52:in `convert_wiki_style_links_with_title_b
    ar!''
        from /home/chris/.local/share/gem/ruby/3.1.0/gems/vimwiki_markdown-0.8.2/lib/vimwiki_markdown/wiki_body.rb:45:in `fixlinks''
        from /home/chris/.local/share/gem/ruby/3.1.0/gems/vimwiki_markdown-0.8.2/lib/vimwiki_markdown/wiki_body.rb:18:in `to_s''
        from /home/chris/.local/share/gem/ruby/3.1.0/gems/vimwiki_markdown-0.8.2/lib/vimwiki_markdown.rb:16:in `convert_wikimarkdown_to_html''
        from /home/chris/.local/share/gem/ruby/3.1.0/gems/vimwiki_markdown-0.8.2/bin/vimwiki_markdown:4:in `<top (required)>''
        from /home/chris/.local/share/gem/ruby/3.1.0/bin/vimwiki_markdown:25:in `load''
        from /home/chris/.local/share/gem/ruby/3.1.0/bin/vimwiki_markdown:25:in `<main>''
    '
    Vimwiki: HTML conversion is done, output: /home/chris/life/site_html/
Poetastrophe commented 2 years ago

Things magically work when I use

$ export RUBYOPT="-KU -E utf-8:utf-8"

I don't understand why ;)

patrickdavey commented 2 years ago

Ah very good. I'll see what I can do. I'm away on holidays at the moment so it'll be at least a week. I'm also surprised the string isn't utf8 by default.

On Fri, 12 Aug 2022, 10:53 Christoffer Rasmussen, @.***> wrote:

Things magically work when I use

$ export RUBYOPT="-KU -E utf-8:utf-8"

I don't understand why ;)

— Reply to this email directly, view it on GitHub https://github.com/patrickdavey/vimwiki_markdown/issues/44#issuecomment-1212935071, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEGEXPUVJ54AXMSLG6UFJLVYYNK7ANCNFSM56LBT4CQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

patrickdavey commented 2 years ago

This is a little bit interesting. I don't quite understand how the input file is being treated like that. Can you attach the .md file here, I'm just curious to see exactly how it is encoded.

Also, can you run vim and then type :set fileencodings and let me know what it prints out.

Bit strange. I tried copying that text into a file and converting it. Mine correctly was written out as UTF-8 and converted fine.

What operating system are you using?

patrickdavey commented 1 year ago

Closing as cannot reproduce. Please re-open if you can either supply the file / give steps to reproduce :)