Skip to content

Commit

Permalink
Fix whitespace & formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Dec 4, 2022
1 parent 637c2ca commit a2fe001
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 26 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,17 @@ Note: speaker notes FTW!

##### Syntax highlighting

~~~mkdn
````mkdn
```js
console.log('Hello world!')
console.log('Hello world!');
```
~~~
````

##### Highlight some lines

You can highlight one line, multiple lines or both.

~~~mkdn
````mkdn
```python [1|3-6]
n = 0
while n < 10:
Expand All @@ -112,7 +112,7 @@ while n < 10:
print(f"{n} is odd")
n += 1
```
~~~
````

### Theme

Expand Down
17 changes: 7 additions & 10 deletions lib/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,19 @@ const render = async (input, extraOptions = {}) => {
};

const renderFile = async (filePath, extraOptions) => {
try{
try {
const content = await fs.readFile(filePath);
return render(content.toString(), extraOptions);
}catch(e)
{
return render("File not found.", extraOptions)
} catch (e) {
return render('File not found.', extraOptions);
}
};

function sanitize(entry)
{
if(entry.includes(".."))
{
entry = sanitize(entry.replace("..",""))
function sanitize(entry) {
if (entry.includes('..')) {
entry = sanitize(entry.replace('..', ''));
}
return entry
return entry;
}

module.exports = async (req, res) => {
Expand Down
12 changes: 10 additions & 2 deletions lib/static.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@
const fs = require('fs-extra');
const path = require('path');
const _ = require('lodash');
const { getOptions, getAssetsDir, getPath, getStaticDir, getSlideOptions, getFilesGlob, getFaviconPath } = require('./config');
const { md, isDirectory, isFile, parseYamlFrontMatter, getFilePaths, isAbsoluteURL } = require('./util');
const {
getOptions,
getAssetsDir,
getPath,
getStaticDir,
getSlideOptions,
getFilesGlob,
getFaviconPath
} = require('./config');
const { md, isDirectory, parseYamlFrontMatter, getFilePaths, isAbsoluteURL } = require('./util');
const { revealBasePath, highlightThemePath } = require('./constants');
const { renderFile } = require('./render');
const { renderListFile } = require('./listing');
Expand Down
15 changes: 6 additions & 9 deletions test/slidify.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ test('should render slides split by horizontal separator', () => {
const actual = slidify('Slide A\n\n---\n\nSlide B');
assert.equal(
actual,
'' +
'<section data-markdown><script type="text/template">Slide A\n</script></section>' +
'<section data-markdown><script type="text/template">Slide A\n</script></section>' +
'<section data-markdown><script type="text/template">\nSlide B</script></section>'
);
});
Expand All @@ -16,8 +15,7 @@ test('should render sub slides split by vertical separator', () => {
const actual = slidify('Slide A\n\n---\n\nSlide B\n\n----\n\nSlide C');
assert.equal(
actual,
'' +
'<section data-markdown><script type="text/template">Slide A\n</script></section>' +
'<section data-markdown><script type="text/template">Slide A\n</script></section>' +
'<section >' +
'<section data-markdown><script type="text/template">\nSlide B\n</script></section>' +
'<section data-markdown><script type="text/template">\nSlide C</script></section>' +
Expand All @@ -29,8 +27,7 @@ test('should render slides split by custom separators', () => {
const actual = slidify('Slide A\n\n\nSlide B\n\nSlide C', { separator: '\n\n\n', verticalSeparator: '\n\n' });
assert.equal(
actual,
'' +
'<section data-markdown><script type="text/template">Slide A</script></section>' +
'<section data-markdown><script type="text/template">Slide A</script></section>' +
'<section >' +
'<section data-markdown><script type="text/template">Slide B</script></section>' +
'<section data-markdown><script type="text/template">Slide C</script></section>' +
Expand All @@ -42,16 +39,16 @@ test('should render speaker notes', () => {
const actual = slidify('Slide A\n\nNote: test');
assert.equal(
actual,
'<section data-markdown><script type="text/template">Slide A\n\n<aside class="notes"><p>test</p>\n</aside></script></section>'
'<section data-markdown>' +
'<script type="text/template">Slide A\n\n<aside class="notes"><p>test</p>\n</aside></script></section>'
);
});

test('should ignore comments (e.g. custom slide attributes)', () => {
const actual = slidify('Slide A\n\n---\n\n<!-- .slide: data-background="./image1.png" -->\nSlide B');
assert.equal(
actual,
'' +
'<section data-markdown><script type="text/template">Slide A\n</script></section>' +
'<section data-markdown><script type="text/template">Slide A\n</script></section>' +
'<section data-markdown><script type="text/template">\n<!-- .slide: data-background="./image1.png" -->\nSlide B</script></section>'
);
});

0 comments on commit a2fe001

Please sign in to comment.