Coverage for src / rendercv / renderer / html.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-03-25 13:49 +0000

1import pathlib 

2 

3from rendercv.schema.models.rendercv_model import RenderCVModel 

4 

5from .path_resolver import resolve_rendercv_file_path 

6from .templater.templater import render_html 

7 

8 

9def generate_html( 

10 rendercv_model: RenderCVModel, markdown_path: pathlib.Path | None 

11) -> pathlib.Path | None: 

12 """Generate HTML file from Markdown source with styling. 

13 

14 Why: 

15 HTML format enables web hosting and sharing CVs online. Converts 

16 Markdown to HTML body and wraps with CSS styling and metadata. 

17 

18 Args: 

19 rendercv_model: CV model for path resolution and rendering context. 

20 markdown_path: Path to Markdown source file. 

21 

22 Returns: 

23 Path to generated HTML file, or None if generation disabled. 

24 """ 

25 if ( 

26 rendercv_model.settings.render_command.dont_generate_html 

27 or markdown_path is None 

28 ): 

29 return None 

30 html_path = resolve_rendercv_file_path( 

31 rendercv_model, rendercv_model.settings.render_command.html_path 

32 ) 

33 html_contents = render_html( 

34 rendercv_model, markdown_path.read_text(encoding="utf-8") 

35 ) 

36 html_path.write_text(html_contents, encoding="utf-8") 

37 return html_path