Skip to content

Allow to specify encoding. #662

@ioquatix

Description

@ioquatix

(raise ::Kramdown::Error, "Missing encoding option on root element"))

In order to convert a small part of the document, I had to copy the encoding:

> Kramdown::Converter::Kramdown.convert(root.children.first)
Traceback (most recent call last):
       16: from /home/samuel/.gem/ruby/2.7.1/gems/utopia-2.15.1/lib/utopia/controller/actions.rb:154:in `block in dispatch'
       15: from /home/samuel/.gem/ruby/2.7.1/gems/utopia-2.15.1/lib/utopia/controller/actions.rb:154:in `instance_exec'
       14: from /home/samuel/Documents/socketry/utopia-project/pages/examples/controller.rb:13:in `block in load_controller_file'
       13: from /home/samuel/Documents/socketry/utopia-project/pages/examples/controller.rb:13:in `find'
       12: from /home/samuel/Documents/socketry/utopia-project/pages/examples/controller.rb:13:in `each'
       11: from /home/samuel/Documents/socketry/utopia-project/lib/utopia/project/base.rb:154:in `examples'
       10: from /home/samuel/Documents/socketry/utopia-project/lib/utopia/project/base.rb:154:in `each_child'
        9: from /home/samuel/Documents/socketry/utopia-project/lib/utopia/project/base.rb:159:in `block in examples'
        8: from /home/samuel/Documents/socketry/utopia-project/lib/utopia/project/base.rb:159:in `new'
        7: from /home/samuel/Documents/socketry/utopia-project/lib/utopia/project/example.rb:44:in `initialize'
        6: from /home/samuel/Documents/socketry/utopia-project/lib/utopia/project/example.rb:59:in `document'
        5: from /home/samuel/Documents/socketry/utopia-project/lib/utopia/project/example.rb:59:in `tap'
        4: from /home/samuel/Documents/socketry/utopia-project/lib/utopia/project/example.rb:72:in `block in document'
        3: from <internal:prelude>:20:in `irb'
        2: from /home/samuel/Documents/socketry/utopia-project/lib/utopia/project/example.rb:5:in `block in document'
        1: from /home/samuel/.gem/ruby/2.7.1/gems/kramdown-2.2.1/lib/kramdown/converter/base.rb:110:in `convert'
Kramdown::Error (Missing encoding option on root element)

> root.children.first.options[:encoding] = root.options[:encoding]

> root.options
=> {:encoding=>#<Encoding:UTF-8>, :location=>1, :options=>{}, :abbrev_defs=>{}, :abbrev_attr=>{}, :footnote_count=>0}

> Kramdown::Converter::Kramdown.convert(root.children.first)
=> ["`utopia-project` easily integrates with GitHub Pages.\n\n", []]

Maybe you could allow:

convert(node, encoding: Encoding::UTF_8)

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions