Comments (4)
This isn’t really an issue with remark-breaks, so I’ll close this.
Ignoring them is indeed part of Markdown, and the CM spec. It’s not something I’m interested in adding.
It’s indeed possible to do basically anything in userland, glad you found something!
micromark, which is getting close, will have lineEndingBlank
tokens, part of the CST, which you could compile to persists in Markdown or HTML
from remark-breaks.
| th |
| -------- |
| td<br>td |
Also: please ask questions in the correct places.
from remark-breaks.
Something like this worked for me
// adopted from
// https://github.com/remarkjs/remark/blob/fbbc3a9cfc66441d05234857b8241a46a077e6e7/packages/remark-parse/lib/tokenize/blank-line.js
import {
Settings,
Processor,
ParserConstructor,
ParserFunction,
} from "unified/types";
import { Node } from "unist";
const reBlankLine = /^[ \t]*(\n|$)/;
export function blankLines(this: Processor<Settings>) {
const parser = this.Parser;
if (!isRemarkParser(parser)) {
throw new Error("Missing parser to attach `blankLines` to");
}
parser.prototype.blockTokenizers.blankLine = blankLine;
// NOTE [email protected] we use depends on [email protected] while we use [email protected]
if (parser.prototype.blockMethods.indexOf("blankLine") === -1) {
parser.prototype.blockMethods.unshift("blankLine");
}
function blankLine(
this: Tokenizer,
eat: (consumed: string) => (node: Node) => void,
value: string,
silent: boolean
): true | void {
let index = 0;
const length = value.length;
let eatenLines = 0;
while (index < length) {
const match = reBlankLine.exec(value.slice(index));
if (match == null) {
break;
}
if (silent) {
return true;
}
// debugger;
const line = match[0];
index += line.length;
const add = eat(line);
// NOTE if we are at start we add break for each line
// otherwise we ignore first line as it's newline of previous block
if (this.atStart === true || eatenLines > 0) {
add({ type: "break" });
}
eatenLines++;
}
}
}
function isRemarkParser(parser: ParserConstructor | ParserFunction) {
return (
parser != null &&
parser.prototype != null &&
parser.prototype.blockTokenizers != null
);
}
type Tokenizer = {
atStart: boolean;
inBlock: boolean;
inLink: boolean;
inList: boolean;
};
from remark-breaks.
How to break line in table ? ( gfm is enabled )
And md file is imported.
i.e md text is not in same file.
from remark-breaks.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from remark-breaks.