|
|
@ -19,6 +19,7 @@ from .output_generator import OutputGenerator |
|
|
|
from .katex import KatexClient |
|
|
|
from .images import ImageProcessor, ImageProcessorNamespaceSearcher |
|
|
|
from .util import inlinify |
|
|
|
from .elements import FileLink |
|
|
|
|
|
|
|
|
|
|
|
class HTMLGenerator(OutputGenerator): |
|
|
@ -194,6 +195,8 @@ class HTMLGenerator(OutputGenerator): |
|
|
|
attributes["width"] = e.attributes["width"] |
|
|
|
if "height" in e.attributes: |
|
|
|
attributes["height"] = e.attributes["height"] |
|
|
|
if "title" in e.attributes: |
|
|
|
attributes["title"] = e.attributes["title"] |
|
|
|
|
|
|
|
if e.title: |
|
|
|
attributes["alt"] = e.title |
|
|
@ -202,7 +205,7 @@ class HTMLGenerator(OutputGenerator): |
|
|
|
HTMLGenerator(fake_out, self.katexClient, self.imageProcessor).generate(e.content) |
|
|
|
attributes["alt"] = fake_out.getvalue() |
|
|
|
|
|
|
|
if len(srcset) != 0: |
|
|
|
if len(srcset) > 1: |
|
|
|
attributes["src"] = srcset[-1][0] |
|
|
|
attributes["srcset"] = ", ".join([" ".join(src) for src in srcset]) |
|
|
|
else: |
|
|
@ -217,6 +220,23 @@ class HTMLGenerator(OutputGenerator): |
|
|
|
|
|
|
|
self.generate(link) |
|
|
|
|
|
|
|
def generate_FileLink(self, e: FileLink): |
|
|
|
url = e.url |
|
|
|
|
|
|
|
# The directory of the current file relative to the current working directory |
|
|
|
source_dir = self.context.dir |
|
|
|
# The directory of the current file relative to the md file we were called on |
|
|
|
rel_dir = self.context.rel_dir |
|
|
|
|
|
|
|
searcher = self.imageProcessor.get_searcher_by_path(url, rel_dir, source_dir) |
|
|
|
url = self.imageProcessor.get_path_without_namespace(url) |
|
|
|
|
|
|
|
url = self.imageProcessor.process_image(url, "", searcher, self.context) |
|
|
|
searcher.publish_image(url) |
|
|
|
url = searcher.get_web_path() + "/" + url |
|
|
|
|
|
|
|
self.generate_Link(Link(*e.content, url=url)) |
|
|
|
|
|
|
|
def generate_InlineGroup(self, e: InlineGroup): |
|
|
|
self.generate_Group(e) |
|
|
|
|
|
|
|