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

revealjs-codeblock should support startFrom attribute for line numbers #201

Open
PeterSommerlad opened this issue Dec 16, 2021 · 0 comments

Comments

@PeterSommerlad
Copy link

While playing with revealjs-codeblock plugin i figured that it does not honor the line numbering attribute from pandoc
startFrom=10 . I could add that with my very limited lua abilities by iterating over the code block attributes and add the attribute manually. Because of my lack of experience with lua I place my " solution " here, but dare not to create a pull request, the solution is suboptimal, because the code block attributes are now iterated twice.

function CodeBlock(block)
  if FORMAT == 'revealjs' then
    local css_classes = {}
    local pre_tag_attributes = {}
    local code_tag_attributes = {}

    for _, class in ipairs(block.classes) do
      if is_numberlines_class(class) then
        if not is_data_line_number_in_attributes(block.attributes) then
          table.insert(block.attributes, {'data-line-numbers', ''})
        end
        for _, attribute in ipairs(block.attributes) do
          if attribute[1] == 'startFrom' then 
            table.insert(block.attributes, {'data-ln-start-from', attribute[2]})
          end
        end
      else
        table.insert(css_classes, class)
      end
    end
... continues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant