mirror of
https://github.com/danog/sass-site.git
synced 2024-11-29 20:19:13 +01:00
update comments
This commit is contained in:
parent
639557c46d
commit
c3e686663d
@ -78,10 +78,9 @@ npm run lint
|
||||
while `render` always parses the partial as a LiquidJS template.
|
||||
- `.md` files are parsed both as Markdown _and_ as LiquidJS templates.
|
||||
- When using Markdown, remember that _indentation and whitespace (e.g newlines)
|
||||
matter_. Use Markdown selectively, especially in files that include other
|
||||
non-Markdown partials.
|
||||
- For example, the `{% codeExample %}` tag renders whitespace that results
|
||||
in unwanted `<p>` tags when parsed as Markdown.
|
||||
matter_. Custom tags attempt to strip leading whitespace from text contents
|
||||
(based on the whitespace of the first line) to allow for indented code blocks
|
||||
-- see the `stripIndent` function in `source/helpers/type.ts` for details.
|
||||
|
||||
## Deploying
|
||||
|
||||
|
@ -46,10 +46,6 @@ import {stripIndent} from '../type';
|
||||
* If `syntax` is either `sass` or `scss`, the first section will be
|
||||
* interpreted as that syntax and the second will be interpreted (or
|
||||
* auto-generated) as the CSS output.
|
||||
*
|
||||
* Note that this template includes whitespace that renders unwanted extra `<p>`
|
||||
* tags when parsed as Markdown. To avoid this, ensure that any usage of
|
||||
* `{% codeExample %}` is *not* within a Markdown file or block.
|
||||
*/
|
||||
export default async function codeExample(
|
||||
contents: string,
|
||||
|
@ -34,15 +34,16 @@ export const getLorem = (type: string, number = 1) => {
|
||||
* @see https://github.com/jamiebuilds/min-indent
|
||||
*/
|
||||
export const stripIndent = (contents: string) => {
|
||||
// Strip leading whitespace based on line with least leading whitespace
|
||||
let text = contents;
|
||||
// Find leading whitespace of first line (ignoring initial newlines)
|
||||
const match = /^[\n\r]*([ \t]*)(?=\S)/.exec(text);
|
||||
const match = /^[\n\r]*([ \t]*)(?=\S)/.exec(contents);
|
||||
if (match?.[1]?.length) {
|
||||
// Strip leading whitespace based on first line
|
||||
text = text.replaceAll(new RegExp(`^[ \\t]{${match[1].length}}`, 'gm'), '');
|
||||
return contents.replaceAll(
|
||||
new RegExp(`^[ \\t]{${match[1].length}}`, 'gm'),
|
||||
''
|
||||
);
|
||||
}
|
||||
return text;
|
||||
return contents;
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user