jgm / djot

A light markup language
https://djot.net
MIT License
1.66k stars 43 forks source link

Quickstart example does not work on a Chromebook (Crostini) #115

Closed ghost closed 1 year ago

ghost commented 1 year ago

Hello, I installed the library with luarocks, but the example in the README does not work. The following code

local djot = require("djot")
local input = "This is *djot*"
local doc = djot.parse(input)
local html = doc:render_html()

yields the error

lua5.4: main.lua:3: attempt to call a nil value (field 'parse')
stack traceback:
        main.lua:3: in main chunk
        [C]: in ?

In an interactive session I see that the table structure is different from what can be found in the Example

> djot = require"djot"
> for k, v in pairs(djot) do print(k,v) end
Parser  table: 0x5c4c8eafefd0
> for k, v in pairs(djot.Parser) do print(k,v) end
add_container   function: 0x5c339792b410
find    function: 0x5c339792b3b0
get_inline_matches      function: 0x5c339792b380
new     function: 0x5c339792b030
build_ast       function: 0x5c339793ad20
render_ast      function: 0x5c339793ad80
issue_warnings  function: 0x5c339793acc0
get_eol function: 0x5c339792b470
render_html     function: 0x5c339793adc0
add_match       function: 0x5c339792b3e0
render_matches  function: 0x5c339793ac50
skip_space      function: 0x5c339792b440
get_matches     function: 0x5c339792b500
finish  function: 0x5c339792b4d0
parse_table_row function: 0x5c339792b060
parse   function: 0x5c339792b4a0
specs   function: 0x5c339792b1b0
> local doc = djot.Parser.parse("This is *djot*")
/usr/local/share/lua/5.4/djot/block.lua:652: attempt to call a nil value (method 'specs')
stack traceback:
        /usr/local/share/lua/5.4/djot/block.lua:652: in field 'parse'
        stdin:1: in main chunk
        [C]: in ?

It still does not work. I also tried out the colon operator to call parse. Help is highly appreciated.

ghost commented 1 year ago

Oh, I'm so sorry. This fork describes how it is done. Thank you anyways.

jgm commented 1 year ago

It looks like you're running old code, which had a different API (the fork also is old).

So, what you tried above should work -- it seems that for some reason you've installed an older version of the code. Did you install from a recently checked-out git repository?

jgm commented 1 year ago

Oh, I'd forgotten that I'd put a version of djot on the luarocks repository. I'll need to update that!

ghost commented 1 year ago

Thank you very much for replying. I will install the new version. :)

jgm commented 1 year ago

For now just install from source as described at https://djot.net. It may be a while before I release a new version on luarocks.