Better coding style
This commit is contained in:
@@ -30,7 +30,7 @@ Future<void> wrapTables() async {
|
||||
}
|
||||
|
||||
// All images that are not nested inside a link will be linkified to themselves.
|
||||
void linkifyImg() {
|
||||
Future<void> linkifyImg() async {
|
||||
querySelectorAll('img').forEach((img) {
|
||||
if (img.parent.tagName == 'P') {
|
||||
final link = Element.a()..attributes['href'] = img.attributes['src'];
|
||||
@@ -41,34 +41,31 @@ void linkifyImg() {
|
||||
}
|
||||
|
||||
Future<void> reorganizeHtml() async {
|
||||
final content = querySelector('#content');
|
||||
|
||||
// Make navbar
|
||||
await makeNavbar().then((navbar) {
|
||||
querySelector('body').insertAdjacentElement('afterBegin', navbar);
|
||||
});
|
||||
final navbar = await makeNavbar();
|
||||
|
||||
// Make header
|
||||
await makeHeader().then((header) {
|
||||
content.insertAdjacentElement('beforeBegin', header);
|
||||
final subtitle = querySelector('.subtitle');
|
||||
if (subtitle != null) {
|
||||
header.append(subtitle);
|
||||
}
|
||||
});
|
||||
final header = await makeHeader();
|
||||
|
||||
// wrap tables in container for better SCSS display
|
||||
await wrapTables();
|
||||
|
||||
linkifyImg();
|
||||
// Make images not linking somewhere link to themselves
|
||||
await linkifyImg();
|
||||
|
||||
// Add navbar to page
|
||||
querySelector('body').insertAdjacentElement('afterBegin', navbar);
|
||||
|
||||
// Add headet to page
|
||||
querySelector('#content').insertAdjacentElement('beforeBegin', header);
|
||||
|
||||
// Add correct class to TOC
|
||||
final toc = (querySelector('#table-of-contents') ??
|
||||
(Element.div()
|
||||
..attributes['id'] = 'table-of-contents'
|
||||
..innerText = "Table of Contents Unavailable"))
|
||||
..innerText = 'Table of Contents Unavailable'))
|
||||
..classes.add('dropdown');
|
||||
querySelector('#toc-drop').append(toc);
|
||||
navbar.querySelector('#toc-drop').append(toc);
|
||||
|
||||
// Remove all <br> tags from HTML
|
||||
querySelectorAll('br').forEach((br) => br.remove());
|
||||
|
||||
Reference in New Issue
Block a user