mirror of
https://github.com/leoncvlt/loconotion.git
synced 2024-08-30 18:12:12 +00:00
Merge pull request #96 from 2m/fix/inner-html-2m
Add inner_html tag attribute (rebase)
This commit is contained in:
commit
ab3ec1a491
@ -162,6 +162,13 @@ theme = "dark"
|
||||
type="text/javascript"
|
||||
src="/example/custom-script.js"
|
||||
|
||||
# the following injects this script in the <head>:
|
||||
# <script>console.log("Hello, world!")</script>
|
||||
[[site.inject.body.script]]
|
||||
inner_html="""
|
||||
console.log("Hello, world!")
|
||||
"""
|
||||
|
||||
## Individual Page Settings ##
|
||||
# the [pages] table defines override settings for individual pages, by defining
|
||||
# a sub-table named after the page url (or part of the url, but careful about
|
||||
|
@ -625,6 +625,12 @@ class Parser:
|
||||
for element in elements:
|
||||
injected_tag = soup.new_tag(tag)
|
||||
for attr, value in element.items():
|
||||
|
||||
# `inner_html` refers to the tag's inner content
|
||||
# and will be added later
|
||||
if attr == "inner_html":
|
||||
continue
|
||||
|
||||
injected_tag[attr] = value
|
||||
# if the value refers to a file, copy it to the dist folder
|
||||
if attr.lower() in ["href", "src"]:
|
||||
@ -636,6 +642,11 @@ class Parser:
|
||||
# shutil.copyfile(source, destination)
|
||||
injected_tag[attr] = str(cached_custom_file) # source.name
|
||||
log.debug(f"Injecting <{section}> tag: {injected_tag}")
|
||||
|
||||
# adding `inner_html` as the tag's content
|
||||
if "inner_html" in element:
|
||||
injected_tag.string = element["inner_html"]
|
||||
|
||||
soup.find(section).append(injected_tag)
|
||||
|
||||
def inject_loconotion_script_and_css(self, soup):
|
||||
|
Loading…
Reference in New Issue
Block a user