forked from FINAKON/HelpProject
1. Initial Commit - a boiler plate code and POC to realize the concept of context sensitive help 2. Frontend code written in ReactJS 3. Backend code written in Java, Spring Boot Framework 4. Frontend Start: pre-requisites : node, npm npm run dev ==> to start the frontend vite server 5. Backend Start: pre-requisites : java, mvn mvn spring-boot:run ==> to start the backend server 6. Visit http://localhost:5173/ for basic demo of help, press F1 in textboxes 7. Visit http://localhost:5173/editor and enter "admin123" to add/modify texts. Happy Coding !!! Thank you, Bhargava.
102 lines
1.8 KiB
JavaScript
102 lines
1.8 KiB
JavaScript
/**
|
|
* @import {
|
|
* Code,
|
|
* Construct,
|
|
* State,
|
|
* TokenizeContext,
|
|
* Tokenizer
|
|
* } from 'micromark-util-types'
|
|
*/
|
|
|
|
import { factorySpace } from 'micromark-factory-space';
|
|
import { markdownLineEnding, markdownSpace } from 'micromark-util-character';
|
|
/** @type {Construct} */
|
|
export const thematicBreak = {
|
|
name: 'thematicBreak',
|
|
tokenize: tokenizeThematicBreak
|
|
};
|
|
|
|
/**
|
|
* @this {TokenizeContext}
|
|
* Context.
|
|
* @type {Tokenizer}
|
|
*/
|
|
function tokenizeThematicBreak(effects, ok, nok) {
|
|
let size = 0;
|
|
/** @type {NonNullable<Code>} */
|
|
let marker;
|
|
return start;
|
|
|
|
/**
|
|
* Start of thematic break.
|
|
*
|
|
* ```markdown
|
|
* > | ***
|
|
* ^
|
|
* ```
|
|
*
|
|
* @type {State}
|
|
*/
|
|
function start(code) {
|
|
effects.enter("thematicBreak");
|
|
// To do: parse indent like `markdown-rs`.
|
|
return before(code);
|
|
}
|
|
|
|
/**
|
|
* After optional whitespace, at marker.
|
|
*
|
|
* ```markdown
|
|
* > | ***
|
|
* ^
|
|
* ```
|
|
*
|
|
* @type {State}
|
|
*/
|
|
function before(code) {
|
|
marker = code;
|
|
return atBreak(code);
|
|
}
|
|
|
|
/**
|
|
* After something, before something else.
|
|
*
|
|
* ```markdown
|
|
* > | ***
|
|
* ^
|
|
* ```
|
|
*
|
|
* @type {State}
|
|
*/
|
|
function atBreak(code) {
|
|
if (code === marker) {
|
|
effects.enter("thematicBreakSequence");
|
|
return sequence(code);
|
|
}
|
|
if (size >= 3 && (code === null || markdownLineEnding(code))) {
|
|
effects.exit("thematicBreak");
|
|
return ok(code);
|
|
}
|
|
return nok(code);
|
|
}
|
|
|
|
/**
|
|
* In sequence.
|
|
*
|
|
* ```markdown
|
|
* > | ***
|
|
* ^
|
|
* ```
|
|
*
|
|
* @type {State}
|
|
*/
|
|
function sequence(code) {
|
|
if (code === marker) {
|
|
effects.consume(code);
|
|
size++;
|
|
return sequence;
|
|
}
|
|
effects.exit("thematicBreakSequence");
|
|
return markdownSpace(code) ? factorySpace(effects, atBreak, "whitespace")(code) : atBreak(code);
|
|
}
|
|
} |