Skip to content
This repository was archived by the owner on Aug 29, 2023. It is now read-only.

Commit 1da620c

Browse files
committed
🐛 Fix scraping error bacause Gist HTML has been changed
1 parent 3ac9ef4 commit 1da620c

1 file changed

Lines changed: 25 additions & 3 deletions

File tree

src/adapters/gistmd.js

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class GistMD extends Adapter {
3838
_isMarkDownPage() {
3939
// find the file name for see the extension
4040
let file_name = this._getFileName();
41-
let extension = file_name.slice(-3); // Now, _isMarkDownPage judges whether the page is MarkDown by finding .gist-header-title class name.
41+
let extension = file_name.slice(-3); // ex. useful_file.md => .md
4242
if (extension === ".md") {
4343
return true;
4444
}
@@ -164,11 +164,33 @@ class GistMD extends Adapter {
164164
}
165165

166166
// _getFileName gets a file name of the MardDown file's Page
167+
// by doing scraping the HTML file.
168+
// [Note] If Gist page HTML structure is changed for this,
169+
// we have to follow the change manually for now.
170+
/// Current HTML structure
171+
/// <body>
172+
/// .
173+
/// .
174+
/// <div class="file-info">
175+
/// <span class="icon">
176+
/// ...
177+
/// </span>
178+
/// <a class="css-truncate" href="#file-docker_cheat-md">
179+
/// <strong class="user-select-contain gist-blob-name css-truncate-target">
180+
/// docker_cheat.md
181+
/// </strong>
182+
/// </a>
183+
/// </div>
184+
/// .
185+
/// .
186+
/// </body>
187+
//
167188
_getFileName() {
168189
return $("body")
169-
.find(".gist-header-title")
190+
.find(".file-info")
170191
.find("a")
171-
.text();
192+
.text()
193+
.trim();
172194
}
173195

174196
}

0 commit comments

Comments
 (0)