Skip to content

Commit

Permalink
feat(highlight): provide an option to disable stripIndent
Browse files Browse the repository at this point in the history
  • Loading branch information
uiolee committed Feb 20, 2024
1 parent 1cf5b21 commit b80086c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/highlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ interface Options {
mark?: number[];
tab?: string;
wrap?: boolean;
disableStripIndent?: boolean
}

function highlightUtil(str: string, options: Options = {}) {
if (typeof str !== 'string') throw new TypeError('str must be a string!');
str = stripIndent(str);
if (!options.disableStripIndent) {
str = stripIndent(str);
}

const useHljs = Object.prototype.hasOwnProperty.call(options, 'hljs') ? options.hljs : false;
const {
Expand Down
5 changes: 4 additions & 1 deletion lib/prism.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,14 @@ interface Options {
lineNumber?: boolean;
mark?: string;
tab?: string;
disableStripIndent?: boolean
}

function PrismUtil(str: string, options: Options = {}) {
if (typeof str !== 'string') throw new TypeError('str must be a string!');
str = stripIndent(str);
if (!options.disableStripIndent) {
str = stripIndent(str);
}

const {
lineNumber = true,
Expand Down

0 comments on commit b80086c

Please sign in to comment.