Skip to content

Commit

Permalink
bugfix: Frontmatter Tag for notes not recognized (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
MSzturc committed Nov 3, 2022
1 parent 0f341c6 commit 10c7478
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 13 deletions.
3 changes: 2 additions & 1 deletion src/defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"template": "template/reveal.html",
"separator": "\r?\n---\r?\n",
"verticalSeparator": "\r?\n--\r?\n",
"notesSeparator": "note:",
"enableLinks": false,
"title": "",
"css": "",
Expand All @@ -14,4 +15,4 @@
"enableCustomControls": true,
"timeForPresentation": 120,
"log": false
}
}
1 change: 1 addition & 0 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export type Options = {
template: string;
separator: string;
verticalSeparator: string;
notesSeparator: string;
enableLinks: boolean;
title: string;
css: string | string[];
Expand Down
12 changes: 9 additions & 3 deletions src/processors/debugViewProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class DebugViewProcessor {
.split(new RegExp(options.verticalSeparator, 'gmi'))
.map((slide, index) => {

const [md, notes] = this.extractNotes(slide);
const [md, notes] = this.extractNotes(slide, options);

let newSlide = this.addDebugCode(md);
if (notes.length > 0) {
Expand Down Expand Up @@ -56,8 +56,14 @@ export class DebugViewProcessor {
return markdown + '\n' + gridBlock;
}

extractNotes(input: string): [string, string] {
const spliceIdx = input.indexOf('note:');
extractNotes(input: string, options: Options): [string, string] {

let noteSeparator = 'note:';
if (options.notesSeparator && options.notesSeparator.length > 0) {
noteSeparator = options.notesSeparator;
}

const spliceIdx = input.indexOf(noteSeparator);
if (spliceIdx > 0) {
return [input.substring(0, spliceIdx), input.substring(spliceIdx)];
} else {
Expand Down
16 changes: 11 additions & 5 deletions src/processors/dropProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class DropProcessor {
.split(new RegExp(options.verticalSeparator, 'gmi'))
.map(slide => {
if (slide.trim().length > 0) {
const newSlide = this.transformSlide(slide);
const newSlide = this.transformSlide(slide, options);
const split = output.split(slide);
if (split.length == 2) {
output = split.join(newSlide);
Expand All @@ -40,8 +40,8 @@ export class DropProcessor {
return output;
}

transformSlide(slide: string) {
const [md, notes] = this.extractNotes(slide);
transformSlide(slide: string, options: Options) {
const [md, notes] = this.extractNotes(slide, options);

let outMd, outSlideComment;

Expand All @@ -68,8 +68,14 @@ export class DropProcessor {
return out;
}

extractNotes(input: string): [string, string] {
const spliceIdx = input.indexOf('note:');
extractNotes(input: string, options: Options): [string, string] {

let noteSeparator = 'note:';
if (options.notesSeparator && options.notesSeparator.length > 0) {
noteSeparator = options.notesSeparator;
}

const spliceIdx = input.indexOf(noteSeparator);
if (spliceIdx > 0) {
return [input.substring(0, spliceIdx), input.substring(spliceIdx)];
} else {
Expand Down
12 changes: 9 additions & 3 deletions src/processors/templateProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class TemplateProcessor {
try {

// eslint-disable-next-line prefer-const
let [md, notes] = this.extractNotes(slide);
let [md, notes] = this.extractNotes(slide, options);

let circuitCounter = 0;
while (this.templateCommentRegex.test(md)) {
Expand Down Expand Up @@ -100,8 +100,14 @@ export class TemplateProcessor {
return output;
}

extractNotes(input: string): [string, string] {
const spliceIdx = input.indexOf('note:');
extractNotes(input: string, options: Options): [string, string] {

let noteSeparator = 'note:';
if (options.notesSeparator && options.notesSeparator.length > 0) {
noteSeparator = options.notesSeparator;
}

const spliceIdx = input.indexOf(noteSeparator);
if (spliceIdx > 0) {
return [input.substring(0, spliceIdx), input.substring(spliceIdx)];
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/yamlParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class YamlParser {
}

getSlidifyOptions(options: unknown) {
const slidifyProps = ['separator', 'verticalSeparator'];
const slidifyProps = ['separator', 'verticalSeparator', 'notesSeparator'];
return _.pick(options, slidifyProps);
}

Expand Down

0 comments on commit 10c7478

Please sign in to comment.