-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #382 from exadel-inc/feature/footnotes-grouping
feat(esl-footnotes): add a grouping of footnotes with non-unique text
- Loading branch information
Showing
5 changed files
with
95 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import type {ESLNote} from './esl-note'; | ||
|
||
export interface FootnotesItem { | ||
index: string; | ||
text: string; | ||
} | ||
|
||
/* Convert notes list to footnotes items list */ | ||
function convertNotesToFootnotesList(notes: ESLNote[]): FootnotesItem[] { | ||
return notes.map(({index, html}) => ({ | ||
index: `${index}`, | ||
text: html | ||
})); | ||
} | ||
|
||
/* Compile footnotes non-grouped list */ | ||
export function compileFootnotesNongroupedList(notes: ESLNote[]): FootnotesItem[] { | ||
return convertNotesToFootnotesList(notes); | ||
} | ||
|
||
/* Compile footnotes grouped list */ | ||
export function compileFootnotesGroupedList(notes: ESLNote[]): FootnotesItem[] { | ||
const map = new Map(); | ||
convertNotesToFootnotesList(notes).forEach(({index, text}) => { | ||
map.set(text, map.has(text) ? `${map.get(text)}, ${index}` : index); | ||
}); | ||
return Array.from(map) | ||
.reduce( | ||
(list,[text, index]) => [...list, {index, text}], | ||
[] | ||
); | ||
} |
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 |
---|---|---|
|
@@ -16,4 +16,8 @@ esl-note { | |
&[tooltip-shown] { | ||
text-decoration: underline; | ||
} | ||
|
||
&.highlight { | ||
font-weight: bold; | ||
} | ||
} |
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