-
Notifications
You must be signed in to change notification settings - Fork 0
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
add slide separator in case no separator is provided and heading indicates the new slide #9
Conversation
c37b6f8
to
1ace1cb
Compare
cda8d47
to
8a62791
Compare
652c263
to
3c1659e
Compare
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.
The description seems not to describe everything that happens in the PR, or is it because its mixed with #8 ?
plugin/awesoMD/plugin.js
Outdated
|
||
// add slide separator in the case heading indicates the new slide | ||
if (options.separateByHeading) { | ||
options['slideSeparator'] = '---' |
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.
still, this is "hardcoded"
what will happen if the app options.separator
is set to +++
but we add ---
as a separator here?
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.
the apps options.separator
doesn't store the separator value, instead it stores the regex pattern of the slide separator. The default regex pattern is stored as const DEFAULT_SLIDE_SEPARATOR = '\r?\n---\r?\n'
. If other pattern is to use then it is defined by attribute data-separator
in the index.html
file as:
<section data-markdown="markdown/simplified.md" data-separator="\r?\n---\r?\n"></section>
The slide separator used in the markdown file and the pattern defined in data-separator
should match. The plugin looks for the slide separator pattern and separates the slide. If different value is used for the slide separator in the markdown file then we should provide that regex pattern in data-separator
attribute, and if this attribute is not specified in the section
tag then the plugin will take the pattern specified in DEFAULT_SLIDE_SEPARATOR
.
In our case, we do not provide slide separator in markdown file, so we somewhere need to specify the value of the slide separator. If we don't want to hard code here in the plugin, we can set this as default slide separator and specify the slide separator in index.html
file as:
<section data-markdown="markdown/simplified.md" data-separator="\r?\n---\r?\n" data-separator-by-heading slide-separator="---"></section>
When there is data-separator-by-heading
attribute, there should be slide-separator
present in the section tag and matching regex pattern in data-separator
attribute. With that we can skip the hard coding slide separator in the plugin.
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.
OK, thank you for the explanation 👍
I now understand the challenge.
I rather would not introduce a new option. Maybe the easiest is to define that when data-separator-by-heading
is used data-separator
cannot be set to anything that is not default.
So then we can keep it hard-codded, but just need to have a check when options.separateByHeading
is set whether options.separator === DEFAULT_SLIDE_SEPARATOR
and if not show an error
const spySeparateInlineMetadataAndMarkdown = jest.fn(plugin().separateInlineMetadataAndMarkdown) | ||
const [markdown, fm] = plugin().parseFrontMatter(markdownContent, {}) | ||
|
||
const slides = markdown.split(/^---\n/gm) |
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.
please create a test with an other separator also, see my comment above
plugin/awesoMD/plugin.js
Outdated
const newMetadata = headingWithMetadataRegex.test(markdown) | ||
yamlRegex.lastIndex = 0 | ||
|
||
if (options.separateByHeading) { |
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.
please add a test that checks if the behavior is correct when this value is set to true
c16ff3d
to
ade9262
Compare
ade9262
to
16ace15
Compare
…arator-by-heading is set to true
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.
last commit should also have a test, rest looks good to me
} | ||
} | ||
|
||
if (animateLists === true) { |
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.
if (animateLists === true) { | |
if (animateLists) { |
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.
Is the type of animatedList
ever checked? If not then I don't think this is good style, because this will be also true for these cases:
animateLists='false'
animatedList=2
Also how does this change relate to the topic of the PR?
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.
These are the codes that we copied from the main reveal.js plugin. The animateLists
variable is true if defined otherwise it is undefined.
This is not actually related to this PR. Maybe the confusion came up because there's a lot of changes in the plugin.js file.
I will revert this change back, since it is the part of code that was copied from reveal.js plugin. 👍
85d6bda
to
23cad6f
Compare
…ided with data-separator-by-heading
23cad6f
to
f4fb43c
Compare
Description
In this PR, adds a new attribute value
data-separator-by-heading
to indicate whether heading represents the start of the new slide. In this case, no slide separator is required and the plugin will add default slide separator above the slide headings.Usage
To use this feature, add the attribute
data-separator-by-heading
in the section tag as below:And the markdown file can be simply provided as: