Skip to content

Add filter revealjs-codeblock #103

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

Merged
merged 9 commits into from
Jul 25, 2020
Merged

Add filter revealjs-codeblock #103

merged 9 commits into from
Jul 25, 2020

Conversation

sokotim
Copy link
Contributor

@sokotim sokotim commented Jul 17, 2020

Adds a filter that passes code block attributes to revealjs HTML output to enable reveal.js code presentation features like line numbers & highlights, step-by-step highlights and auto-animation.

@tarleb
Copy link
Member

tarleb commented Jul 20, 2020

Thank you for the PR! It will take me a little longer to review, but should be able to do so next week.

Copy link
Member

@tarleb tarleb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, this is great! Nice, clean code and well documented.

I left a few inline comments, but those should be treated as minor remarks.

end

function CodeBlock(block)
if FORMAT == 'revealjs' then
Copy link
Member

@tarleb tarleb Jul 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could go to the top of the file, like so:

if FORMAT ~= 'revealjs' then
  return {}
end

That way the filter can exit early and the code becomes a little less nested.

end

local function is_data_line_number_in_attributes(attributes)
for _, attribute in ipairs(attributes) do
Copy link
Member

@tarleb tarleb Jul 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attributes come with a metatable which allows using the structure just like an associative table. E.g., this could be written as

for key, value in pairs(attributes) do
    if key == 'data-line-numbers' then return true end
end

We would have changed the ipairs behavior as well, but Lua 5.3 does not allow this.

end
if block.identifier ~= '' then
table.insert(pre_tag_attributes,
string.format('id="%s"', block.identifier))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be extracted in a separate function like html_attr or the like.

@tarleb tarleb merged commit cbd128c into pandoc:master Jul 25, 2020
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

Successfully merging this pull request may close these issues.

2 participants