-
-
Notifications
You must be signed in to change notification settings - Fork 170
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
Conversation
Thank you for the PR! It will take me a little longer to review, but should be able to do so next week. |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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.
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.