Skip to content

Commit 63c5e7f

Browse files
committed
refactor: remove underscore prefix from private methods
1 parent 6a5b0d9 commit 63c5e7f

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

shared/jekyll-markdown-parser.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ export const MARKDOWN_BASE_URL_PLACEHOLDER = '%%MARKDOWN_BASE_URL%%';
3131
* The literal `s*` matches zero or more 's' characters, not whitespace.
3232
* It worked accidentally because most files use `---\n` without trailing chars.
3333
*
34-
* 2. FEATURE: Added _imageRenderer() to transform relative image paths to
34+
* 2. FEATURE: Added imageRenderer() to transform relative image paths to
3535
* absolute URLs using baseUrl (for CDN/deployment support).
3636
*
37-
* 3. FEATURE: Added _transformRelativeImagePaths() to handle raw HTML <img>
37+
* 3. FEATURE: Added transformRelativeImagePaths() to handle raw HTML <img>
3838
* tags that bypass the markdown renderer.
3939
*
4040
* 4. CHANGE: Converted from CommonJS module to ES6 class with constructor
@@ -57,7 +57,7 @@ export class JekyllMarkdownParser {
5757

5858
private createMarkedInstance(): Marked {
5959
const renderer = new Renderer();
60-
renderer.image = this._imageRenderer.bind(this);
60+
renderer.image = this.imageRenderer.bind(this);
6161

6262
return new Marked(
6363
markedHighlight({
@@ -72,7 +72,7 @@ export class JekyllMarkdownParser {
7272
* Check if a URL is absolute (should not be transformed).
7373
* Absolute URLs include: https://, http://, data:, //, assets/, /
7474
*/
75-
private _isAbsoluteUrl(url: string): boolean {
75+
private isAbsoluteUrl(url: string): boolean {
7676
return url.startsWith('https://') || url.startsWith('http://') ||
7777
url.startsWith('data:') || url.startsWith('//') ||
7878
url.startsWith('assets/') || url.startsWith('/') ||
@@ -82,14 +82,14 @@ export class JekyllMarkdownParser {
8282
/**
8383
* Normalize a relative URL by stripping ./ prefix.
8484
*/
85-
private _normalizeRelativeUrl(url: string): string {
85+
private normalizeRelativeUrl(url: string): string {
8686
return url.startsWith('./') ? url.slice(2) : url;
8787
}
8888

8989
/**
9090
* Escape special HTML characters in attribute values.
9191
*/
92-
private _escapeHtml(text: string): string {
92+
private escapeHtml(text: string): string {
9393
return text
9494
.replace(/&/g, '&amp;')
9595
.replace(/"/g, '&quot;')
@@ -104,30 +104,30 @@ export class JekyllMarkdownParser {
104104
* NOTE: In marked v17, the token contains RAW unescaped text.
105105
* We MUST escape special characters to prevent broken HTML.
106106
*/
107-
private _imageRenderer(token: Tokens.Image): string {
107+
private imageRenderer(token: Tokens.Image): string {
108108
let src = token.href;
109109

110-
if (!this._isAbsoluteUrl(token.href)) {
111-
src = this.baseUrl + this._normalizeRelativeUrl(token.href);
110+
if (!this.isAbsoluteUrl(token.href)) {
111+
src = this.baseUrl + this.normalizeRelativeUrl(token.href);
112112
}
113113

114-
const escapedAlt = this._escapeHtml(token.text);
114+
const escapedAlt = this.escapeHtml(token.text);
115115
let out = `<img src="${src}" alt="${escapedAlt}"`;
116116
if (token.title) {
117-
out += ` title="${this._escapeHtml(token.title)}"`;
117+
out += ` title="${this.escapeHtml(token.title)}"`;
118118
}
119119
out += '>';
120120
return out;
121121
}
122122

123123
// Transform relative paths in raw HTML <img> tags to absolute URLs
124124
// Supports both double quotes (src="...") and single quotes (src='...')
125-
private _transformRelativeImagePaths(html: string): string {
125+
private transformRelativeImagePaths(html: string): string {
126126
return html.replace(/<img([^>]*)\ssrc=(["'])([^"']+)\2/g, (match, attrs, quote, src) => {
127-
if (this._isAbsoluteUrl(src)) {
127+
if (this.isAbsoluteUrl(src)) {
128128
return match;
129129
}
130-
return `<img${attrs} src=${quote}${this.baseUrl}${this._normalizeRelativeUrl(src)}${quote}`;
130+
return `<img${attrs} src=${quote}${this.baseUrl}${this.normalizeRelativeUrl(src)}${quote}`;
131131
});
132132
}
133133

@@ -159,7 +159,7 @@ export class JekyllMarkdownParser {
159159

160160
private compileMarkdown(markdown: string): string {
161161
const html = this.marked.parse(markdown) as string;
162-
return this._transformRelativeImagePaths(html);
162+
return this.transformRelativeImagePaths(html);
163163
}
164164

165165
private parseYaml(yaml: string): Record<string, unknown> {

0 commit comments

Comments
 (0)