Skip to content

Commit 105d5c3

Browse files
committed
reorganized parser
1 parent e6b5aa4 commit 105d5c3

File tree

7 files changed

+830
-549
lines changed

7 files changed

+830
-549
lines changed

README.html

Lines changed: 256 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,87 @@
1-
# lurkdown [![npm version](https://badge.fury.io/js/lurkdown.svg)](https://badge.fury.io/js/lurkdown)
1+
# lurkdown
22

3-
lurkdown is a markdown transpiler that was built on nodejs with typescript to create standalone html files. lurkdown converts all locally hosted image files to base64 to avoid dealing with images when we want to host that html files somewhere. I mainly developed this to convert my markdown formatted notes to html and then use them like static blog posts. lurkdown is a command line tool. I will make a *library* version that will be usable in web and nodejs projects later.
3+
[![npm version](https://badge.fury.io/js/lurkdown.svg)](https://badge.fury.io/js/lurkdown)
44

5-
![](https://raw.githubusercontent.com/obsfx/lurkdown/master/demo.gif)
5+
[View the source code on GitHub](https://github.com/obsfx/lurkdown)
6+
7+
8+
9+
![lurkdown](https://raw.githubusercontent.com/obsfx/lurkdown/gh-pages/demo.gif)
10+
11+
12+
13+
`lurkdown` is a command-line markdown transpiler tool that was built on `NodeJS` with `TypeScript` to create standalone, markdown-generated HTML files. `lurkdown` converts all locally hosted image files to `base64` to avoid dealing with images when we want to host that HTML files at somewhere. *It is not perfect but works in most cases.*
614

715

816

917
## installation
1018

1119
You can directly install via npm
1220

21+
22+
1323
```
1424
npm i -g lurkdown
1525
```
1626

27+
28+
1729
Or you can download the standalone executable version.
1830

1931
[Standalone Executables](https://github.com/obsfx/lurkdown/releases)
2032

33+
34+
2135
## disclaimer
2236

2337
some core features are not implemented:
2438

25-
1. Combined blockquotes. *because it sucks.*
26-
2. Reference style images. *I don't need it*
39+
1. Combined blockquotes.
40+
2. Reference style images.
2741

2842
restrictions:
2943

30-
1. lurkdown doesn't deal with font files. You have to host them somewhere and @import the css file of font definitions.
44+
1. `lurkdown` doesn't deal with font files. You have to host them at somewhere and `@import` the `CSS` file of font definitions.
3145

3246

3347

3448
## how to use
3549

36-
You can directly use with command line arguments.
50+
You can directly use with command-line parameters.
3751

38-
```
39-
--theme // optional. available themes: darkand light. if you dont specify a theme, html file will be exported without any default styling.
52+
- `--files` / **_mandatory_** -> Specify file paths by enclosing with quotes and then separating with commas.
53+
`e.g. --files='./path/to/file.md, ./path/to/file2.md, ./path/to/file3.md'`
4054

41-
--files // mandatory. specify file paths by enclosing with quotes and seperating with commas.
42-
e.g. --files='./path/to/file.md, ./path/to/file2.md, ./path/to/file3.md'
55+
- `--theme` / __*optional*__ -> Available themes: dark, light. If you don't specify a theme, output files will be exported without any styling.
4356

44-
--titles // optional. specify the titles that will be used in <title></title> tag in html files. they should be specified in the same order as files and as like files they should be enclosed with quotes and sepeated with commas.
45-
e.g --titles='file title, file2 title, file3 title'
57+
- `--titles` / __*optional*__ -> Specify the titles that will be used in `title` tag in output files. They should be specified in the same order as files and they should be enclosed with quotes and then separated with commas.
58+
`e.g --titles='file title, file2 title, file3 title'`
4659

47-
--outdir // optional. if you don't specify a output directory, files will be exported in same directory as like input files.
60+
- `--outdir` / __*optional*__ -> If you don't specify an output directory, files will be exported in same directory as like input files.
4861

49-
--styles // optional. specify the custom css file paths if you want to customize the outputed html files. they are specified like files and titles. enclose with quotes and seperate with commas.
50-
e.g. --styles='./path/to/cssfile.css, ./path/to/cssfile2.css'
62+
- `--styles` / __*optional*__ -> Specify the custom `CSS` file paths If you want to customize the output files. They should be specified like files and titles. Enclose with quotes and then separate with commas.
63+
`e.g. --styles='./path/to/cssfile.css, ./path/to/cssfile2.css'`
5164

52-
--favico // optional. specify the path of favicon file.
65+
- `--favico` / __*optional*__ -> Specify the path of favico file.
5366

54-
npx ts-node ./src/index.ts --theme=dark --files='./src/test/http_notes.md, ./src/test/test.md' --titles='deneme deneme, deneme2 deneme2' --outdir=./src/export/test --favico=./src/icon.ico
55-
```
5667

57-
example
5868

59-
```
60-
lurkdown --theme=light --files='./src/test/http_notes.md' --titles='http notes' --outdir=./src/export --styles=./src/templates/themes/light/customizations.css --favico=./src/icon.ico
69+
Example usage
70+
71+
6172

73+
```
74+
lurkdown --theme=dark --files='./src/test/http_notes.md, ./src/test/post.md' --titles='HTTP Notes, My First Blog Post' --outdir=./export --favico=./src/icon.ico
6275
```
6376

6477

6578

66-
Or you can just pass a sing config.json file with the `--config`.
79+
Or you can just pass a single `config.json` file with the `--config` parameter.
6780

6881
Example usage:
6982

83+
84+
7085
```json
7186
{
7287
"favico": "./favicon.ico",
@@ -92,7 +107,9 @@ lurkdown --config=./config.json
92107

93108
## customization
94109

95-
You can customize the elements by using this css class names.
110+
You can customize the elements by using this `CSS` class names.
111+
112+
96113

97114
```css
98115
.ld-wrapper { }
@@ -133,5 +150,6 @@ You can customize the elements by using this css class names.
133150
.ld-td { }
134151
```
135152

136-
lurkdown uses [highlight.js](https://github.com/highlightjs/highlight.js) to deal with syntax highlighting so if you want to customize the syntax highlighting, you can pass the [customized css files](https://highlightjs.org/static/demo/) with the `--styles` parameter.
153+
---
137154

155+
`lurkdown` uses [highlight.js](https://github.com/highlightjs/highlight.js) to deal with syntax highlighting so if you want to customize the syntax highlighting, you can pass the [customized css files](https://highlightjs.org/static/demo/) with the `--styles` parameter.

demo.gif

-7.82 MB
Binary file not shown.

src/emitter/index.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import config from '../config'
2-
import Parser from '../parser'
3-
import Utils from '../parser/Utils'
4-
import Element from '../parser/Element'
2+
import {
3+
Block,
4+
Utils,
5+
Element
6+
} from '../parser'
57

68
import fs from 'fs'
79
import path from 'path'
@@ -16,9 +18,11 @@ const emitter = (
1618
) => {
1719
console.log('generating html files...');
1820
let basehtml: string = fs.readFileSync(config.base, 'utf8');
19-
let favicon64: string = Utils.b64(favico);
2021

21-
basehtml = basehtml.replace(config.favico, `<link rel="icon" type="${favicon64.split(';')[0].split(':')[1]}" href="${favicon64}" >`);
22+
if (favico != '') {
23+
let favicon64: string = Utils.b64(favico);
24+
basehtml = basehtml.replace(config.favico, `<link rel="icon" type="${favicon64.split(';')[0].split(':')[1]}" href="${favicon64}" >`);
25+
}
2226

2327
let css: string = '';
2428

@@ -48,7 +52,7 @@ const emitter = (
4852
path.join(outdir, `${parsedpath.name}.html`);
4953

5054
console.log(`parsing '${p}' file...`);
51-
let parser: Parser = new Parser(markdown);
55+
let parser: Block = new Block(markdown);
5256
let body: Element = parser.parse();
5357
let html: string = body.emitHtml();
5458

0 commit comments

Comments
 (0)