-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introducing a new parameter to get additional metadata (#1926)
* extract SotD and abstract if additionaMetadata=true is specified * describe additional metadata * fix parameter name * skip section title for abstract
- Loading branch information
Showing
8 changed files
with
96 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Pseudo-profile for additional metadata extraction. | ||
*/ | ||
|
||
import { rules as baseRules } from './metadata.js'; | ||
import { insertAfter } from './profileUtil.js'; | ||
|
||
import * as abstract from '../rules/metadata/abstract.js'; | ||
import * as sotd from '../rules/metadata/sotd.js'; | ||
|
||
export const name = 'AdditionalMetadata'; | ||
|
||
export const rules = insertAfter(baseRules, 'metadata.errata', [ | ||
abstract, | ||
sotd, | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Pseudo-rule for metadata extraction: abstract. | ||
*/ | ||
|
||
export const name = 'metadata.abstract'; | ||
|
||
/** | ||
* @param sr | ||
* @param done | ||
*/ | ||
export function check(sr, done) { | ||
let abstractTitle; | ||
Array.prototype.some.call(sr.jsDocument.querySelectorAll('h2'), h2 => { | ||
if (sr.norm(h2.textContent).toLowerCase() === 'abstract') { | ||
abstractTitle = h2; | ||
return true; | ||
} | ||
}); | ||
|
||
if (abstractTitle) { | ||
const div = sr.jsDocument.createElement('div'); | ||
[...abstractTitle.parentElement.children].forEach(child => { | ||
{ | ||
if (child !== abstractTitle) { | ||
div.appendChild(child.cloneNode(true)); | ||
} | ||
} | ||
}); | ||
return done({ abstract: sr.norm(div.innerHTML) }); | ||
} else { | ||
return done({ abstract: 'Not found' }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Pseudo-rule for metadata extraction: sotd. | ||
*/ | ||
|
||
export const name = 'metadata.sotd'; | ||
|
||
/** | ||
* @param sr | ||
* @param done | ||
*/ | ||
export function check(sr, done) { | ||
const sotd = sr.getSotDSection(); | ||
return done({ sotd: sotd ? sr.norm(sotd.innerHTML) : 'Not found' }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters