default

ReSpec to EPUB

Classes

c
OCF

Convenience class to export the internal OCF class for the package as a whole. Conversion methods or functions return an instance of this class, containing the generated EPUB content.

c
RespecToEPUB

Convenience class, to export the internal RespecToEPUB class for the package as a whole. (This is only useful if, for some reasons, the conversion is done starting with a DOM tree, using create_epub_from_dom. In general, convert should be used).

Functions

f
convert(
url: string,
options?: Options,
trace?: boolean,
packageOnly?: boolean
): Promise<OCF>

The top level entry in the package: convert a single Respec file, or a collection thereof, into an EPUB document.

Interfaces

I
Options

Options provided by the user if and when the source has to be pre-processed via ReSpec.

Variables

v
ENV_MODIFIED_FILE_LOCATION: "R2EPUB_MODIFIED_EPUB_FILES"

Environmental variable name for the location of external copies of some css and image files

v
spec_status_values: string[]

Valid Spec Status values

cli

CLI for the ReSpec to EPUB 3.4 conversion.

serve

Simple server for EPUB generation

lib/common.ts

Global constants used at various places.

Enums

Functions

Interfaces

I
ConfigOptions

Config options, to be used as part of the arguments in [[Options]] to overwrite the configuration options of ReSpec.

I
Options

Options provided by the user if and when the source has to be pre-processed via ReSpec.

Variables

v
acceptable_url_endings: string[]

Acceptable endings for document URL-s. We try to avoid cases when the relative URL calculations go wrong

v
entity_codes: string[][]

Entity/code pairs: the XHTML conversion is supposed to remove the XML entities (if used) to their code alternatives.

v
ENV_MODIFIED_FILE_LOCATION: "R2EPUB_MODIFIED_EPUB_FILES"

Environmental variable name for the location of external copies of some css and image files

v
environment

Flag to decide whether the code runs in a browser, in Deno, or in node.js.

v
fixup_js: string

Generic 'fixup' script (used for warnings for rescinded or obsolete versions).

v
invalid_host_names: string[]

Invalid host names (essentially "localhost" and friends); unless explicitly set in the environment, these are considered to be unsafe. This is important for server deployment: servers should never accept these host names

v
local_port_number: "80"

Default port number for the server locally. Set to the default HTTP port number; the environment variable PORT may, however, overwrite this for a server.

v
local_style_files: string

Local (relative) URL for styles and logos

v
media_types: MediaType

Various media types used in the code.

v
modified_epub_files: string

Base URL for the W3C files (like base.css, logos in SVG format) modified for EPUB.

v
process_2021_date: "2021-11-02"

Cut-off date for the publication process change

v
process_version: number

Process version being used

v
spec_generator: "https://www.w3.org/publications/spec-generator/?type=respec&url="

URL of the spec generator service, used if the source has to be transformed via respec first.

v
spec_status_values: string[]

Valid Spec Status values

v
text_content: string[]

These media types refer to textual content, no reason to bother about streaming when fetching them...

v
TR_css_files: string

Base URL for the official W3C css files (only the non-SVG ones are used directly).

v
tr_epub_css: ` body { /* Layout */ max-width: 50em; /* limit line length to 50em for readability */ margin: 0 auto !important; /* center text within page, space for footers */ padding: 1.6em 1.5em 2em 50px; /* assume 16px font size for downlevel clients */ padding: 1.6em 1.5em 2em calc(26px + 1.5em); /* leave space for status flag */ } div[role~="main"] { margin: 0 auto; /* center text within page */ max-width: none; padding: 1.6em 1.5em 2em 50px; /* assume 16px font size for downlevel clients */ padding: 1.6em 1.5em 2em calc(26px + 1.5em); /* leave space for status flag */ } body { max-width: 100% !important; } h2 { page-break-before: always; page-break-inside: avoid; page-break-after: avoid; } div.head h2 { page-break-before: auto; page-break-inside: avoid; page-break-after: avoid; } figure { page-break-inside: avoid; } h3, h4, h5 { page-break-after: avoid; } dl dt { page-break-after: avoid; } dl dd { page-break-before: avoid; } div.example, div.note, pre.idl, .warning, table.parameters, table.exceptions { page-break-inside: avoid; } p { orphans: 4; widows: 2; } .outdated-warning { position: absolute; border-style: solid; border-color: red; } .outdated-warning input { display: none; } p.copyright, p.copyright small { font-size: small; } #toc-nav, #toc-toggle-inline { display:none !important; } #back-to-top, .toc-toggle { display: none !important; } nav#toc { display: none } `

Extra CSS file for EPUB content; mainly used to adapt and, possibly, to compensate the effects of the main CSS file. The features are

v
TR_logo_files: string

Base URL for the official W3C logos (only the non-SVG ones are used directly).

v
W3C_icons: "https://www.w3.org/Icons/"

Generic ICON directory on the W3C site

v
wcag_checked: string[]

Document types that are supposed to be WCAG A level due to the W3C publication check.

lib/convert.ts

Main entry points

Classes

c
RespecToEPUB(
trace?: boolean,
print_package?: boolean
)

Main Processing class

Interfaces

I
Global

Interface of the "Global" data, to be used by various utilities

  • config: any

    The initial config object, originally filled by the user (respec puts a copy of this object, as JSON, into the header of the generated content).

  • document_url: string

    The URL of the document to be processed

  • dom: jsdom.JSDOM

    The DOM element, as returned from parsing

  • html_element: Element

    The DOM HTML element of the main document

  • opf_content: opf.PackageWrapper

    The class used for the generation of the EPUB opf file

  • package: boolean

    [Debug] Whether the opf instance should be should be printed to the console instead of generating an EPUB file

  • process_version: number

    Process version used to generate this file. The possible values are 2016 and 2021

  • resources: ResourceRef[]

    List of extra resources, to be added to the opf file and into the final EPUB file. The main role of the [[create_epub_from_dom]] function is to collect all relevant resources; once done, this array is used to generate the final package.opf file as well as to collect the resources themselves and add them to the final epub file.

  • trace: boolean

    [Debug] Whether trace information should be printed to the console

I
ResourceRef

Interface for the resources that, eventually, should be added to the EPUB file

lib/cover.ts

Cover page

Functions

f
create_cover_image(global: Global): ResourceRef[]

Create the cover image: it is an SVG file with title, the type of the document, date, and a W3C Logo.

Variables

v
cover_svg: `<?xml version="1.0" encoding="UTF-8"?> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" viewBox="0 0 595 842"> <desc> Cover page for the EPUB file. It consists of three items: (1) the title of the publication, (2) the denomination of the W3C Technical Report type (Note, Draft, Recommendation, etc.) and (3) the Large logo of W3C. The three items are stacked vertically and horizontally centered, with the Title on the top the logo in the bottom and the type in the middle. </desc> <foreignObject style="overflow: visible; text-align: left;" pointer-events="none" y="200" width="100%" height="100%"> <div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: center; justify-content: center"> <div style="display: inline-block; font-size: 40px; font-family: sans-serif; color: #005A9C; line-height: 1.2; font-weight: bold; font-style: italic; white-space: nowrap; text-align: center"> %%%TITLE%%% </div> </div> </foreignObject> <foreignObject style="overflow: visible; text-align: left;" pointer-events="none" y="400" width="100%" height="100%"> <div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: center; justify-content: center"> <div style="display: inline-block; font-size: 20px; font-family: sans-serif; color: #005A9C; line-height: 1.3; font-weight: bold; white-space: nowrap; text-align: center; "> %%%SUBTITLE%%% </div> </div> </foreignObject> <svg x="140" y="700" width="315" height="48" viewBox="0 0 83.343748 12.7" xml:space="preserve"> <defs id="defs1"/> <path style="fill:none;fill-rule:evenodd;stroke:#002a56;stroke-width:0.264583px" d="M 23.984033,0 V 12.699999" id="path1011" transform="translate(-8.0953313)"/> <g id="g1" transform="matrix(0.0339848,0,0,0.0339848,0.0899577,0.21399008)"> <g id="g2" style="fill:#005a9c"> <path d="m 306.80028,149.60422 c -6.57831,-5.22164 -16.18258,-4.11126 -21.40437,2.46705 -6.46763,8.15442 -12.34209,13.06271 -19.03895,15.91953 -12.3507,5.25562 -22.8198,3.03441 -32.94112,-6.99345 -9.91806,-9.82474 -19.58153,-20.53078 -28.95701,-30.90671 -4.58604,-5.07758 -9.18023,-10.16361 -13.83407,-15.19045 -7.95131,-8.58691 -15.94475,-17.14014 -23.93018,-25.70183 l -0.70385,-0.7546 C 148.6218,69.85421 130.66786,50.62862 113.34968,31.3183 99.61724,16.00055 78.39966,8.41364 57.98727,11.48232 37.12548,14.60189 20.25655,27.95303 10.48285,49.06883 c -9.41762,20.33598 -6.23039,43.44391 8.30724,60.30423 25.57483,29.66072 47.14864,54.18407 72.41783,77.24986 10.33349,9.42608 22.83701,14.44431 36.15387,14.51211 8.6381,0.0426 21.65838,-0.93219 34.94171,-9.87548 5.81526,-3.91601 11.23186,-7.94285 13.6139,-14.08852 2.42447,-6.28959 0.16098,-13.52028 -5.51838,-17.59771 -5.51007,-3.9672 -12.74075,-3.68767 -17.99637,0.67804 -0.66142,0.55074 -1.38204,1.18679 -2.17002,1.87358 -8.2565,7.23069 -18.53079,16.23288 -39.47715,1.1948 C 91.56416,149.53641 76.70442,131.47223 59.48772,110.55154 53.87602,103.73584 48.06936,96.68319 41.86434,89.47773 35.23528,81.78948 33.80265,71.21044 38.12593,61.86032 41.89832,53.72266 49.17975,43.60119 62.50551,41.60936 c 10.09566,-1.51765 21.41238,2.5172 28.16859,10.04507 17.4624,19.47975 35.55195,38.85772 53.04802,57.58302 8.1973,8.77371 16.39415,17.55557 24.54902,26.36326 4.56927,4.93366 9.0789,9.92608 13.65633,14.99535 9.61287,10.63868 19.54755,21.63315 30.04203,32.0343 18.94578,18.7759 42.49435,23.53152 66.33996,13.38482 11.45233,-4.89123 21.29399,-12.83408 30.95745,-25.01519 5.21304,-6.56941 4.11126,-16.16552 -2.46661,-21.39577 z" id="path1-9"/> <path d="m 330.6361,64.98331 c 9.85011,-4.6709 17.59815,-13.46152 18.33554,-24.12543 1.87344,-18.51314 -13.36805,-36.22984 -35.78948,-38.96811 -13.76627,-1.74599 -26.541,2.33145 -35.59408,9.83349 -4.84019,4.02639 -6.14582,11.4777 -1.94984,16.73332 4.58589,5.46749 9.87548,6.42505 18.53064,1.67002 3.10236,-1.7632 7.76481,-3.22981 12.89328,-2.87403 9.67207,0.67003 12.44387,9.38409 12.17266,13.34268 -0.0426,0.58501 0.0171,14.07992 -13.60529,13.13912 l -5.13707,-0.35579 c -5.72179,-0.39021 -11.44387,4.95888 -11.86746,11.07889 -0.45801,6.51066 4.30622,12.19832 10.23127,12.6139 l 6.31526,0.43219 c 17.37798,1.20385 15.56374,15.95335 15.19935,18.31017 -0.33902,6.78143 -11.22355,18.28435 -30.6355,5.20443 C 283.14876,96.58494 236.17,37.57744 236.17,37.57744 213.90999,8.79861 176.0861,3.72935 146.23903,25.53194 c -3.2804,2.3988 -5.44226,5.93366 -6.06941,9.9605 -0.61884,4.01779 0.35593,8.04448 2.75503,11.32488 2.3988,3.2804 5.93381,5.44226 9.95189,6.06941 4.04316,0.62745 8.05279,-0.35593 11.33349,-2.75503 20.36135,-14.87665 38.51024,-6.01022 47.84315,6.06111 0,0 50.43765,64.87335 63.4241,71.74796 8.42608,4.45903 17.22516,7.03588 26.168,7.65487 27.44827,1.89866 44.16438,-13.22414 48.67445,-33.94142 2.958,-13.57992 -5.82387,-30.55048 -19.68361,-36.67093 z" id="path2"/> </g> <g id="g5" style="fill:#002a56" aria-label="W3C"> <path d="m 7.65638,245.62164 h 18.68735 c 1.9807,0 3.61006,0.4556 4.88419,1.35908 1.27413,0.90348 2.13515,2.09267 2.59075,3.56759 l 16.64873,65.1509 c 0.96139,3.3977 1.86874,7.33594 2.71816,11.80701 0.45174,-2.20851 0.90348,-4.31662 1.35908,-6.33208 0.45174,-2.00773 0.98842,-3.86102 1.61391,-5.55987 l 19.70666,-65.06596 c 0.45174,-1.30503 1.32819,-2.44789 2.63322,-3.44403 1.30116,-0.98842 2.85716,-1.48263 4.67184,-1.48263 h 6.54057 c 1.9807,0 3.57917,0.44016 4.79925,1.31275 1.21622,0.88031 2.08109,2.08495 2.59075,3.61392 l 19.70666,65.1509 c 0.56371,1.6448 1.08881,3.43631 1.57144,5.39771 0.47877,1.94596 0.94595,4.00002 1.40155,6.15447 0.39382,-2.15445 0.80695,-4.19307 1.23167,-6.11586 0.42472,-1.92279 0.86101,-3.70658 1.31661,-5.35138 l 16.64873,-65.23585 c 0.39382,-1.30503 1.25869,-2.44789 2.59075,-3.44403 1.32819,-0.98842 2.89963,-1.48263 4.71431,-1.48263 h 17.49816 L 130.31337,358.4253 H 110.09705 L 87.75717,283.42107 c -0.33977,-0.96526 -0.66796,-2.03862 -0.97684,-3.22782 -0.31274,-1.1892 -0.61004,-2.43244 -0.8919,-3.73747 -0.28572,1.30503 -0.5946,2.54828 -0.93437,3.73747 -0.33977,1.18919 -0.65251,2.26256 -0.93437,3.22782 L 61.2551,358.4253 H 41.12373 Z" id="path3"/> <path d="m 212.19794,244.34751 c 5.20852,0 9.8958,0.76448 14.05798,2.29345 4.16218,1.52897 7.6873,3.61392 10.57534,6.23941 2.88805,2.64094 5.10813,5.72204 6.66799,9.26646 1.55599,3.5367 2.33592,7.31278 2.33592,11.33596 0,3.56759 -0.38224,6.71046 -1.14672,9.42862 -0.76448,2.71816 -1.88418,5.09655 -3.35523,7.13517 -1.47491,2.03862 -3.28573,3.76836 -5.43632,5.18149 -2.15445,1.41313 -4.5869,2.57916 -7.30506,3.48264 12.85335,4.36296 19.28195,13.05026 19.28195,26.07735 0,5.72204 -1.03475,10.74909 -3.1004,15.07343 -2.06951,4.33979 -4.84172,7.97687 -8.32437,10.91897 -3.48265,2.9421 -7.53286,5.1506 -12.14678,6.62552 -4.61778,1.47491 -9.47109,2.20851 -14.56764,2.20851 -5.38227,0 -10.1236,-0.62549 -14.22787,-1.86874 -4.10813,-1.24325 -7.70274,-3.12743 -10.7877,-5.65254 -3.08882,-2.51739 -5.74906,-5.64482 -7.9846,-9.38229 -2.23939,-3.73747 -4.1506,-8.06954 -5.73362,-12.9962 l 9.00391,-3.82241 c 2.37839,-0.96526 4.59848,-1.20464 6.66799,-0.71815 2.06565,0.47877 3.52511,1.59846 4.37454,3.35137 1.01931,1.92279 2.09267,3.72203 3.22782,5.38999 1.13128,1.67568 2.42086,3.15059 3.86488,4.41701 1.44402,1.28186 3.1004,2.28573 4.96914,3.01932 1.86874,0.73359 4.01932,1.10425 6.45563,1.10425 3.00001,0 5.61779,-0.49421 7.85718,-1.48263 2.23553,-0.99614 4.08882,-2.30117 5.56373,-3.90736 1.47105,-1.62163 2.5753,-3.44403 3.31276,-5.48265 0.73359,-2.03862 1.10425,-4.07724 1.10425,-6.11586 0,-2.60233 -0.24324,-4.98072 -0.72201,-7.13517 -0.48263,-2.15445 -1.55985,-3.9923 -3.22782,-5.52126 -1.67182,-1.52897 -4.11971,-2.71816 -7.34753,-3.56759 -3.22782,-0.84943 -7.6178,-1.27414 -13.16609,-1.27414 v -14.52517 c 4.64095,-0.0541 8.45178,-0.47877 11.42477,-1.27414 2.97299,-0.79537 5.30891,-1.91507 7.00776,-3.35137 1.69885,-1.45174 2.85716,-3.15832 3.48264,-5.14288 0.62162,-1.98457 0.93437,-4.19307 0.93437,-6.62552 0,-5.1506 -1.28958,-9.03479 -3.86488,-11.63712 -2.57916,-2.60233 -6.18922,-3.90736 -10.83017,-3.90736 -4.13516,0 -7.59077,1.15831 -10.36299,3.48264 -2.77608,2.32434 -4.70273,5.18149 -5.77609,8.57919 -0.90734,2.60233 -2.11198,4.30118 -3.61006,5.09655 -1.50194,0.79537 -3.64094,0.96526 -6.41316,0.50966 l -10.7877,-1.86874 c 0.79151,-5.49037 2.29345,-10.29349 4.50195,-14.40162 2.20851,-4.10041 4.98072,-7.52899 8.32437,-10.27032 3.33978,-2.74905 7.14675,-4.81856 11.42477,-6.20853 4.27415,-1.38225 8.87649,-2.07723 13.80316,-2.07723 z" id="path4-4"/> <path d="m 335.38002,331.07381 c 1.1892,0 2.20851,0.4556 3.05793,1.35908 l 8.91896,9.5985 c -4.07724,5.72204 -9.18923,10.07727 -15.33212,13.08115 -6.14675,3.00388 -13.43636,4.50195 -21.8727,4.50195 -7.64483,0 -14.52517,-1.42858 -20.64103,-4.29346 -6.11586,-2.85716 -11.3128,-6.84945 -15.58695,-11.96917 -4.27801,-5.12744 -7.55988,-11.21241 -9.85333,-18.27036 -2.29345,-7.04251 -3.44017,-14.76455 -3.44017,-23.14297 0,-8.4402 1.23167,-16.17769 3.695,-23.23564 2.46333,-7.04251 5.93053,-13.11976 10.40546,-18.21631 4.47106,-5.09655 9.82244,-9.05796 16.05413,-11.89195 6.22783,-2.83399 13.08115,-4.24713 20.55609,-4.24713 7.58691,0 14.29737,1.34364 20.13137,4.03863 5.83014,2.68727 10.70276,6.23941 14.61011,10.65642 l -7.47494,10.44793 c -0.50966,0.62549 -1.09267,1.1892 -1.74132,1.69885 -0.65251,0.50966 -1.57144,0.76448 -2.76063,0.76448 -1.18919,0 -2.33592,-0.4556 -3.44017,-1.35908 -1.10425,-0.90348 -2.46333,-1.89962 -4.07724,-2.97299 -1.61391,-1.07337 -3.64094,-2.06951 -6.07339,-2.97299 -2.43631,-0.90348 -5.55215,-1.35908 -9.34368,-1.35908 -4.13516,0 -7.89965,0.86487 -11.29735,2.59461 -3.3977,1.72202 -6.31663,4.24713 -8.74908,7.55216 -2.43631,3.32048 -4.32048,7.36683 -5.64868,12.1545 -1.33205,4.77995 -1.99615,10.23171 -1.99615,16.34757 0,6.16991 0.73359,11.66801 2.20851,16.47885 1.47105,4.81083 3.4672,8.87263 5.98845,12.19311 2.51739,3.30504 5.47879,5.83014 8.87649,7.55216 3.3977,1.72974 7.05023,2.59461 10.95758,2.59461 2.32047,0 4.41701,-0.12355 6.28575,-0.3861 1.86874,-0.24711 3.61006,-0.70271 5.22396,-1.35908 1.61391,-0.64865 3.12743,-1.48263 4.54442,-2.50194 1.41313,-1.01931 2.83013,-2.29345 4.24713,-3.82241 0.56371,-0.4556 1.14672,-0.83398 1.74132,-1.15058 0.5946,-0.30888 1.20078,-0.46332 1.82626,-0.46332 z" id="path5-7"/> </g> </g> <g id="text2" style="font-size:32px;line-height:90%;font-family:Carlito;-inkscape-font-specification:Carlito;letter-spacing:1.08736px;word-spacing:0px;fill:#002a56;stroke-width:1px" transform="matrix(0.24332542,0,0,0.24332542,4.6484834,15.61009)" aria-label="WORLD WIDE WEB&#xA;CONSORTIUM"> <path style="line-height:90%" d="m 62.114105,-62.819096 h 2.390625 q 0.359375,0 0.609375,0.1875 0.265625,0.171875 0.34375,0.46875 l 3.984375,14.171875 q 0.21875,0.75 0.40625,1.75 0.09375,-0.484375 0.203125,-0.921875 0.109375,-0.453125 0.234375,-0.84375 l 4.578125,-14.140625 q 0.07813,-0.265625 0.34375,-0.46875 0.265625,-0.203125 0.625,-0.203125 h 0.828125 q 0.375,0 0.609375,0.1875 0.25,0.171875 0.34375,0.46875 l 4.578125,14.171875 q 0.125,0.375 0.234375,0.8125 0.109375,0.421875 0.203125,0.890625 0.09375,-0.46875 0.1875,-0.90625 0.09375,-0.4375 0.203125,-0.796875 l 3.96875,-14.15625 q 0.07813,-0.265625 0.34375,-0.46875 0.28125,-0.203125 0.640625,-0.203125 h 2.234375 l -6.234375,20.53125 h -2.578125 l -4.9375,-15.5625 q -0.07813,-0.21875 -0.15625,-0.46875 -0.0625,-0.265625 -0.140625,-0.5625 -0.0625,0.296875 -0.140625,0.5625 -0.0625,0.25 -0.140625,0.46875 l -4.96875,15.5625 h -2.5625 z m 49.087365,10.265625 q 0,2.3125 -0.6875,4.234375 -0.67188,1.921875 -1.92188,3.3125 -1.23437,1.390625 -2.98437,2.171875 -1.73438,0.765625 -3.85938,0.765625 -2.109374,0 -3.859374,-0.765625 -1.75,-0.78125 -3,-2.171875 -1.25,-1.390625 -1.9375,-3.3125 -0.6875,-1.921875 -0.6875,-4.234375 0,-2.296875 0.6875,-4.21875 0.6875,-1.9375 1.9375,-3.328125 1.25,-1.40625 3,-2.171875 1.75,-0.78125 3.859374,-0.78125 2.125,0 3.85938,0.78125 1.75,0.765625 2.98437,2.171875 1.25,1.390625 1.92188,3.328125 0.6875,1.921875 0.6875,4.21875 z m -2.90625,0 q 0,-1.875 -0.46875,-3.359375 -0.45313,-1.5 -1.3125,-2.53125 -0.84375,-1.046875 -2.0625,-1.59375 -1.20313,-0.5625 -2.70313,-0.5625 -1.5,0 -2.718749,0.5625 -1.203125,0.546875 -2.0625,1.59375 -0.859375,1.03125 -1.328125,2.53125 -0.453125,1.484375 -0.453125,3.359375 0,1.875 0.453125,3.375 0.46875,1.484375 1.328125,2.53125 0.859375,1.03125 2.0625,1.578125 1.218749,0.546875 2.718749,0.546875 1.5,0 2.70313,-0.546875 1.21875,-0.546875 2.0625,-1.578125 0.85937,-1.046875 1.3125,-2.53125 0.46875,-1.5 0.46875,-3.375 z m 10.25923,1.734375 v 8.53125 h -2.84375 v -20.53125 h 5.625 q 1.875,0 3.23438,0.40625 1.375,0.390625 2.25,1.140625 0.89062,0.734375 1.3125,1.796875 0.42187,1.046875 0.42187,2.359375 0,1.078125 -0.32812,2.015625 -0.3125,0.9375 -0.92188,1.6875 -0.59375,0.75 -1.46875,1.296875 -0.875,0.53125 -1.98437,0.8125 0.26562,0.171875 0.5,0.390625 0.23437,0.203125 0.45312,0.5 l 5.51563,8.125 h -2.53125 q -0.73438,0 -1.14063,-0.578125 l -4.85937,-7.3125 q -0.23438,-0.34375 -0.51563,-0.484375 -0.26562,-0.15625 -0.8125,-0.15625 z m 0,-2.078125 h 2.67188 q 1.125,0 1.96875,-0.28125 0.85937,-0.296875 1.4375,-0.828125 0.57812,-0.53125 0.85937,-1.265625 0.29688,-0.75 0.29688,-1.640625 0,-3.671875 -4.45313,-3.671875 h -2.78125 z m 18.32173,8.21875 h 7.92188 v 2.390625 h -10.76563 v -20.53125 h 2.84375 z m 28.16549,-7.875 q 0,2.3125 -0.6875,4.203125 -0.67187,1.890625 -1.90625,3.25 -1.21875,1.34375 -2.95312,2.078125 -1.71875,0.734375 -3.8125,0.734375 h -7.09375 v -20.53125 h 7.09375 q 2.09375,0 3.8125,0.75 1.73437,0.734375 2.95312,2.078125 1.23438,1.34375 1.90625,3.25 0.6875,1.890625 0.6875,4.1875 z m -2.92187,0 q 0,-1.875 -0.45313,-3.34375 -0.45312,-1.484375 -1.29687,-2.515625 -0.84375,-1.03125 -2.03125,-1.5625 -1.1875,-0.546875 -2.65625,-0.546875 h -4.23438 v 15.9375 h 4.23438 q 1.46875,0 2.65625,-0.53125 1.1875,-0.546875 2.03125,-1.5625 0.84375,-1.03125 1.29687,-2.515625 0.45313,-1.484375 0.45313,-3.359375 z m 13.58097,-10.265625 h 2.39062 q 0.35938,0 0.60938,0.1875 0.26562,0.171875 0.34375,0.46875 l 3.98437,14.171875 q 0.21875,0.75 0.40625,1.75 0.0937,-0.484375 0.20313,-0.921875 0.10937,-0.453125 0.23437,-0.84375 l 4.57813,-14.140625 q 0.0781,-0.265625 0.34375,-0.46875 0.26562,-0.203125 0.625,-0.203125 h 0.82812 q 0.375,0 0.60938,0.1875 0.25,0.171875 0.34375,0.46875 l 4.57812,14.171875 q 0.125,0.375 0.23438,0.8125 0.10937,0.421875 0.20312,0.890625 0.0937,-0.46875 0.1875,-0.90625 0.0937,-0.4375 0.20313,-0.796875 l 3.96875,-14.15625 q 0.0781,-0.265625 0.34375,-0.46875 0.28125,-0.203125 0.64062,-0.203125 h 2.23438 l -6.23438,20.53125 h -2.57812 l -4.9375,-15.5625 q -0.0781,-0.21875 -0.15625,-0.46875 -0.0625,-0.265625 -0.14063,-0.5625 -0.0625,0.296875 -0.14062,0.5625 -0.0625,0.25 -0.14063,0.46875 l -4.96875,15.5625 h -2.5625 z m 34.82174,20.53125 h -2.84375 v -20.53125 h 2.84375 z m 22.32173,-10.265625 q 0,2.3125 -0.6875,4.203125 -0.67188,1.890625 -1.90625,3.25 -1.21875,1.34375 -2.95313,2.078125 -1.71875,0.734375 -3.8125,0.734375 h -7.09375 v -20.53125 h 7.09375 q 2.09375,0 3.8125,0.75 1.73438,0.734375 2.95313,2.078125 1.23437,1.34375 1.90625,3.25 0.6875,1.890625 0.6875,4.1875 z m -2.92188,0 q 0,-1.875 -0.45312,-3.34375 -0.45313,-1.484375 -1.29688,-2.515625 -0.84375,-1.03125 -2.03125,-1.5625 -1.1875,-0.546875 -2.65625,-0.546875 h -4.23437 v 15.9375 h 4.23437 q 1.46875,0 2.65625,-0.53125 1.1875,-0.546875 2.03125,-1.5625 0.84375,-1.03125 1.29688,-2.515625 0.45312,-1.484375 0.45312,-3.359375 z m 19.33736,-10.265625 v 2.3125 h -9.14063 v 6.734375 h 7.35938 v 2.234375 h -7.35938 v 6.9375 h 9.15625 l -0.0156,2.3125 h -12 v -20.53125 z m 10.95596,0 h 2.39063 q 0.35937,0 0.60937,0.1875 0.26563,0.171875 0.34375,0.46875 l 3.98438,14.171875 q 0.21875,0.75 0.40625,1.75 0.0937,-0.484375 0.20312,-0.921875 0.10938,-0.453125 0.23438,-0.84375 l 4.57812,-14.140625 q 0.0781,-0.265625 0.34375,-0.46875 0.26563,-0.203125 0.625,-0.203125 h 0.82813 q 0.375,0 0.60937,0.1875 0.25,0.171875 0.34375,0.46875 l 4.57813,14.171875 q 0.125,0.375 0.23437,0.8125 0.10938,0.421875 0.20313,0.890625 0.0937,-0.46875 0.1875,-0.90625 0.0937,-0.4375 0.20312,-0.796875 l 3.96875,-14.15625 q 0.0781,-0.265625 0.34375,-0.46875 0.28125,-0.203125 0.64063,-0.203125 h 2.23437 l -6.23437,20.53125 h -2.57813 l -4.9375,-15.5625 q -0.0781,-0.21875 -0.15625,-0.46875 -0.0625,-0.265625 -0.14062,-0.5625 -0.0625,0.296875 -0.14063,0.5625 -0.0625,0.25 -0.14062,0.46875 l -4.96875,15.5625 h -2.5625 z m 43.63425,0 v 2.3125 h -9.14063 v 6.734375 h 7.35938 v 2.234375 h -7.35938 v 6.9375 h 9.15625 l -0.0156,2.3125 h -12 v -20.53125 z m 4.69673,20.53125 v -20.53125 h 6.26563 q 1.8125,0 3.10937,0.375 1.3125,0.359375 2.14063,1.0625 0.84375,0.6875 1.23437,1.6875 0.39063,0.984375 0.39063,2.234375 0,0.75 -0.23438,1.453125 -0.21875,0.703125 -0.67187,1.296875 -0.45313,0.59375 -1.14063,1.078125 -0.6875,0.484375 -1.625,0.78125 2.14063,0.421875 3.21875,1.609375 1.09375,1.171875 1.09375,3.09375 0,1.3125 -0.45312,2.390625 -0.45313,1.078125 -1.32813,1.859375 -0.875,0.765625 -2.15625,1.1875 -1.26562,0.421875 -2.90625,0.421875 z m 2.84375,-9.34375 v 7.09375 h 4.04688 q 1.07812,0 1.84375,-0.265625 0.78125,-0.28125 1.26562,-0.765625 0.5,-0.484375 0.71875,-1.15625 0.23438,-0.6875 0.23438,-1.484375 0,-1.578125 -1,-2.5 -0.98438,-0.921875 -3.0625,-0.921875 z m 0,-2 h 3.3125 q 1.04688,0 1.82813,-0.25 0.78125,-0.265625 1.29687,-0.71875 0.51563,-0.453125 0.76563,-1.09375 0.26562,-0.640625 0.26562,-1.421875 0,-1.796875 -0.98437,-2.625 -0.96875,-0.84375 -3.0625,-0.84375 h -3.42188 z" id="path6"/> <path style="line-height:90%" d="m 76.832855,-17.769096 q 0.21875,0 0.40625,0.1875 l 1.125,1.21875 q -1.109375,1.46875 -2.734375,2.28125 -1.625,0.8125 -3.890625,0.8125 -2,0 -3.625,-0.765625 -1.609375,-0.765625 -2.765625,-2.140625 -1.140625,-1.390625 -1.765625,-3.3125 -0.609375,-1.9375 -0.609375,-4.265625 0,-2.328125 0.65625,-4.25 0.65625,-1.9375 1.84375,-3.328125 1.1875,-1.390625 2.84375,-2.15625 1.65625,-0.765625 3.65625,-0.765625 1.984375,0 3.484375,0.703125 1.515625,0.703125 2.640625,1.90625 l -0.9375,1.3125 q -0.09375,0.140625 -0.234375,0.234375 -0.140625,0.09375 -0.359375,0.09375 -0.265625,0 -0.59375,-0.28125 -0.3125,-0.28125 -0.828125,-0.609375 -0.515625,-0.34375 -1.28125,-0.625 -0.765625,-0.28125 -1.90625,-0.28125 -1.34375,0 -2.46875,0.546875 -1.109375,0.546875 -1.921875,1.59375 -0.796875,1.03125 -1.25,2.53125 -0.4375,1.484375 -0.4375,3.375 0,1.90625 0.46875,3.40625 0.46875,1.5 1.28125,2.53125 0.8125,1.03125 1.90625,1.578125 1.109375,0.546875 2.375,0.546875 0.78125,0 1.390625,-0.109375 0.625,-0.109375 1.140625,-0.328125 0.53125,-0.234375 0.984375,-0.578125 0.46875,-0.359375 0.921875,-0.84375 0.25,-0.21875 0.484375,-0.21875 z m 23.024861,-5.984375 q 0,2.3125 -0.6875,4.234375 -0.671875,1.921875 -1.921875,3.3125 -1.234375,1.390625 -2.984375,2.171875 -1.734375,0.765625 -3.859375,0.765625 -2.109375,0 -3.859375,-0.765625 -1.75,-0.78125 -3,-2.171875 -1.25,-1.390625 -1.9375,-3.3125 -0.6875,-1.921875 -0.6875,-4.234375 0,-2.296875 0.6875,-4.21875 0.6875,-1.9375 1.9375,-3.328125 1.25,-1.40625 3,-2.171875 1.75,-0.78125 3.859375,-0.78125 2.125,0 3.859375,0.78125 1.75,0.765625 2.984375,2.171875 1.25,1.390625 1.921875,3.328125 0.6875,1.921875 0.6875,4.21875 z m -2.90625,0 q 0,-1.875 -0.46875,-3.359375 -0.453125,-1.5 -1.3125,-2.53125 -0.84375,-1.046875 -2.0625,-1.59375 -1.203125,-0.5625 -2.703125,-0.5625 -1.5,0 -2.71875,0.5625 -1.203125,0.546875 -2.0625,1.59375 -0.859375,1.03125 -1.328125,2.53125 -0.453125,1.484375 -0.453125,3.359375 0,1.875 0.453125,3.375 0.46875,1.484375 1.328125,2.53125 0.859375,1.03125 2.0625,1.578125 1.21875,0.546875 2.71875,0.546875 1.5,0 2.703125,-0.546875 1.21875,-0.546875 2.0625,-1.578125 0.859375,-1.046875 1.3125,-2.53125 0.46875,-1.5 0.46875,-3.375 z m 8.915484,-10.265625 q 0.35938,0 0.54688,0.09375 0.1875,0.07813 0.42187,0.390625 l 11.15625,15.359375 q -0.0312,-0.375 -0.0625,-0.734375 -0.0156,-0.375 -0.0156,-0.6875 v -14.421875 h 2.5 v 20.53125 h -1.4375 q -0.32813,0 -0.5625,-0.109375 -0.21875,-0.109375 -0.4375,-0.390625 l -11.15625,-15.3125 q 0.0312,0.359375 0.0469,0.6875 0.0156,0.328125 0.0156,0.625 v 14.5 h -2.5 v -20.53125 h 1.48437 z m 30.39986,3.234375 q -0.23437,0.4375 -0.64062,0.4375 -0.23438,0 -0.5625,-0.234375 -0.3125,-0.25 -0.78125,-0.53125 -0.45313,-0.296875 -1.10938,-0.53125 -0.64062,-0.25 -1.54687,-0.25 -0.85938,0 -1.51563,0.25 -0.64062,0.234375 -1.07812,0.671875 -0.42188,0.421875 -0.64063,1 -0.21875,0.5625 -0.21875,1.21875 0,0.859375 0.39063,1.421875 0.40625,0.5625 1.04687,0.96875 0.65625,0.390625 1.48438,0.6875 0.82812,0.296875 1.6875,0.609375 0.85937,0.3125 1.6875,0.71875 0.82812,0.390625 1.46875,1 0.65625,0.59375 1.04687,1.46875 0.40625,0.875 0.40625,2.140625 0,1.359375 -0.4375,2.546875 -0.4375,1.171875 -1.28125,2.046875 -0.82812,0.875 -2.04687,1.375 -1.21875,0.5 -2.78125,0.5 -1.89063,0 -3.48438,-0.71875 -1.57812,-0.734375 -2.6875,-1.96875 l 0.82813,-1.34375 q 0.10937,-0.171875 0.26562,-0.265625 0.17188,-0.109375 0.39063,-0.109375 0.29687,0 0.65625,0.328125 0.375,0.3125 0.92187,0.703125 0.54688,0.375 1.3125,0.703125 0.78125,0.3125 1.85938,0.3125 0.90625,0 1.60937,-0.265625 0.70313,-0.265625 1.1875,-0.75 0.5,-0.484375 0.75,-1.15625 0.26563,-0.6875 0.26563,-1.515625 0,-0.921875 -0.40625,-1.515625 -0.39063,-0.59375 -1.04688,-0.984375 -0.64062,-0.40625 -1.46875,-0.671875 -0.82812,-0.28125 -1.6875,-0.578125 -0.85937,-0.296875 -1.6875,-0.671875 -0.82812,-0.390625 -1.48437,-1.015625 -0.64063,-0.625 -1.04688,-1.546875 -0.39062,-0.921875 -0.39062,-2.296875 0,-1.078125 0.40625,-2.09375 0.40625,-1.03125 1.17187,-1.8125 0.78125,-0.796875 1.90625,-1.265625 1.14063,-0.484375 2.60938,-0.484375 1.64062,0 3,0.546875 1.375,0.546875 2.375,1.59375 z m 23.39986,7.03125 q 0,2.3125 -0.6875,4.234375 -0.67187,1.921875 -1.92187,3.3125 -1.23438,1.390625 -2.98438,2.171875 -1.73437,0.765625 -3.85937,0.765625 -2.10938,0 -3.85938,-0.765625 -1.75,-0.78125 -3,-2.171875 -1.25,-1.390625 -1.9375,-3.3125 -0.6875,-1.921875 -0.6875,-4.234375 0,-2.296875 0.6875,-4.21875 0.6875,-1.9375 1.9375,-3.328125 1.25,-1.40625 3,-2.171875 1.75,-0.78125 3.85938,-0.78125 2.125,0 3.85937,0.78125 1.75,0.765625 2.98438,2.171875 1.25,1.390625 1.92187,3.328125 0.6875,1.921875 0.6875,4.21875 z m -2.90625,0 q 0,-1.875 -0.46875,-3.359375 -0.45312,-1.5 -1.3125,-2.53125 -0.84375,-1.046875 -2.0625,-1.59375 -1.20312,-0.5625 -2.70312,-0.5625 -1.5,0 -2.71875,0.5625 -1.20313,0.546875 -2.0625,1.59375 -0.85938,1.03125 -1.32813,2.53125 -0.45312,1.484375 -0.45312,3.359375 0,1.875 0.45312,3.375 0.46875,1.484375 1.32813,2.53125 0.85937,1.03125 2.0625,1.578125 1.21875,0.546875 2.71875,0.546875 1.5,0 2.70312,-0.546875 1.21875,-0.546875 2.0625,-1.578125 0.85938,-1.046875 1.3125,-2.53125 0.46875,-1.5 0.46875,-3.375 z m 10.25923,1.734375 v 8.53125 h -2.84375 v -20.53125 h 5.625 q 1.875,0 3.23438,0.40625 1.375,0.390625 2.25,1.140625 0.89062,0.734375 1.3125,1.796875 0.42187,1.046875 0.42187,2.359375 0,1.078125 -0.32812,2.015625 -0.3125,0.9375 -0.92188,1.6875 -0.59375,0.75 -1.46875,1.296875 -0.875,0.53125 -1.98437,0.8125 0.26562,0.171875 0.5,0.390625 0.23437,0.203125 0.45312,0.5 l 5.51563,8.125 h -2.53125 q -0.73438,0 -1.14063,-0.578125 l -4.85937,-7.3125 q -0.23438,-0.34375 -0.51563,-0.484375 -0.26562,-0.15625 -0.8125,-0.15625 z m 0,-2.078125 h 2.67188 q 1.125,0 1.96875,-0.28125 0.85937,-0.296875 1.4375,-0.828125 0.57812,-0.53125 0.85937,-1.265625 0.29688,-0.75 0.29688,-1.640625 0,-3.671875 -4.45313,-3.671875 h -2.78125 z m 28.22799,-9.921875 v 2.375 h -5.98437 v 18.15625 h -2.85938 v -18.15625 h -6 v -2.375 z m 6.91549,20.53125 h -2.84375 v -20.53125 h 2.84375 z m 13.96236,-2.25 q 1.23437,0 2.20312,-0.421875 0.98438,-0.4375 1.65625,-1.203125 0.67188,-0.78125 1.01563,-1.84375 0.35937,-1.0625 0.35937,-2.34375 v -12.46875 h 2.84375 v 12.46875 q 0,1.78125 -0.5625,3.296875 -0.5625,1.515625 -1.60937,2.625 -1.03125,1.109375 -2.53125,1.75 -1.5,0.625 -3.375,0.625 -1.875,0 -3.375,-0.625 -1.48438,-0.640625 -2.53125,-1.75 -1.04688,-1.109375 -1.60938,-2.625 -0.5625,-1.515625 -0.5625,-3.296875 v -12.46875 h 2.84375 v 12.453125 q 0,1.28125 0.34375,2.359375 0.35938,1.0625 1.03125,1.84375 0.67188,0.765625 1.64063,1.203125 0.98437,0.421875 2.21875,0.421875 z m 24.39985,-5.234375 q 0.20313,0.359375 0.35938,0.734375 0.17187,0.375 0.32812,0.765625 0.15625,-0.40625 0.3125,-0.78125 0.17188,-0.375 0.35938,-0.71875 l 7.25,-12.578125 q 0.1875,-0.328125 0.40625,-0.390625 0.21875,-0.07813 0.59375,-0.07813 h 2.09375 v 20.53125 h -2.51563 v -14.984375 q 0,-0.3125 0.0156,-0.6875 0.0312,-0.390625 0.0625,-0.78125 l -7.32813,12.875 q -0.35937,0.640625 -1.03125,0.640625 h -0.40625 q -0.67187,0 -1.03125,-0.640625 l -7.5,-12.859375 q 0.0937,0.78125 0.0937,1.453125 v 14.984375 h -2.5 v -20.53125 h 2.09375 q 0.375,0 0.57813,0.07813 0.21875,0.0625 0.42187,0.40625 l 7.34375,12.5625 z" id="path7"/> </g> </svg> </svg> `

The SVG template to be used for the cover image.

lib/css2016.ts

CSS files (for the 2016 version of the Process)

Functions

f
extract_css(global: Global): ResourceRef[]

Extract/add the right CSS references and gathers all resources (logo files, watermark image, etc.) to be added to the overall set of resources in the final book. Note that the HTML DOM of the main file is modified on the fly:

lib/css2021.ts

CSS files (for the 2021 version of the Process)

Functions

f
extract_css(global: Global): ResourceRef[]

Extract/add the right CSS references and gathers all resources (logo files, watermark image, etc.) to be added to the overall set of resources in the final book. Note that the HTML DOM of the main file is modified on the fly:

lib/defontSvg.ts

Handle a nasty bug in some SVG files

Functions

f
deFontSvg(svg_text: string): string

Replace all occurrences of the <font> element in the SVG file by a <span>.

lib/fetch.ts

Fetch

Functions

f
fetch_html(html_url: string): Promise<jsdom.JSDOM>

Fetch an HTML file via [[fetch_resource]] and parse the result into a DOM instance.

f
fetch_json(json_url: string): Promise<any>

Fetch an JSON file via [[fetch_resource]] and parse the result into an object.

f
fetch_type(resource_url: string): Promise<string>

Fetch the media type of the resource.

lib/home.ts

Service home page

Variables

v
homepage: `<!doctype html> <html> <head> <meta charset='utf-8'> <title>Service to convert W3C Technical Reports to EPUB 3</title> <link rel='stylesheet' href='https://iherman.github.io/r2epub/assets/css/convert.css' /> </head> <body> <main> <h1>Service to convert W3C Technical Reports to EPUB 3</h1> <p>This is an interface an on-line service to convert W3C Technical Reports, authored in <a href="https://respec.org/docs/">ReSpec</a>, to EPUB 3</p> <p> The service receives the parameters through the form above, and generates an EPUB 3 instance stored on the local machine. The possible form parameters are: </p> <dl> <dt id='url'><code>url</code></dt> <dd>The URL for the either the (HTML) content <em>or</em> for the <a href='https://iherman.github.io/r2epub/typedoc/modules/_clib_args_.html'>(JSON) configuration file</a> for a collection of documents. In the second case all other parameter values are ignored. <em>This value is required</em>.</dd> <dt id='respec'><code>respec</code></dt> <dd>Whether the source has to be pre-processed by ReSpec (“true”) or is a final HTML (“false”). If the former, the source is converted using <a href="https://github.com/w3c/spec-generator">W3C’s Spec Generator</a> into HTML first.</dd> <dt id='pdate'><code>publishDate</code></dt> <dd><sup>(☨)</sup>Publication date. Overwrites the <a href='https://github.com/w3c/respec/wiki/publishDate'>value in the “<code>respecConfig</code>” structure</a> in the source.</dd> <dt id="status"><code>specStatus</code></dt> <dd>Specification date. Overwrites the <a href='https://github.com/w3c/respec/wiki/specStatus'>value in the “<code>respecConfig</code>” structure</a> in the source.</dd> <dt id='seclink'><code>addSectionLinks</code></dt> <dd>Add section links with a <code>§</code> character. Overwrites the <a href='https://github.com/w3c/respec/wiki/addSectionLinks'>value in the “<code>respecConfig</code>” structure</a> in the source.</dd> <dt id='toclevel'><code>maxTocLevel</code></dt> <dd>Maximum sectioning level for the Table of Content. Overwrites the <a href='https://github.com/w3c/respec/wiki/maxTocLevel'>value in the “<code>respecConfig</code>” structure</a> in the source.</dd> </dl> <p> By default, the value of <code>respec</code> is <code>false</code>. However, if one of <code>publishDate</code>, <code>specStatus</code>, <code>addSectionLinks</code>, or <code>maxTocLevel</code> are set, <code>respec=true</code> is implied (i.e., it is not necessary to set it explicitly). </p> <h2>Usage examples</h2> <p> Convert the HTML file (as generated by ReSpec) to an EPUB 3 file. The generated publication's name is <code>short-name.epub</code>, where <code>short-name</code> is set in the ReSpec configuration: </p> <pre>%%%SERVER%%%?url=https://www.example.org/doc.html</pre> <p>Convert the HTML <em>ReSpec source</em> to an EPUB 3 file. The source is converted on-the-fly by respec:</p> <pre>%%%SERVER%%%?url=https://www.example.org/doc.html&respec=true</pre> <p>Convert the HTML <em>ReSpec source</em> to an EPUB 3 file, setting its spec status to REC. The source is converted on-the-fly by respec, overwriting the <code>specStatus</code> entry in the configuration to <code>REC</code>:</p> <pre>%%%SERVER%%%?url=https://www.example.org/doc.html&respec=true&specStatus=REC</pre> <p>Generates a collection of HTML documents to an EPUB 3 file, described by a <a href='https://iherman.github.io/r2epub/typedoc/modules/_clib_args_.html'>(JSON) configuration file</a>:</p> <pre>%%%SERVER%%%?url=https://www.example.org/collection.json</pre> </main> <footer style='font-size:80%; border-top: thin solid black;'> <p>This server runs the <a href='https://github.com/iherman/r2epub/'>r2epub</a> script; see the <a href='https://iherman.github.io/r2epub/'>documentation</a> for more details. Copyright © 2025 <a href='https://www.ivan-herman.net/'>Ivan Herman</a>. </p> </footer> </body> </html> `
lib/nav.ts

Navigation File

Functions

f
create_nav_file(global: Global): ResourceRef[]

Create a navigation file, and return the necessary resource (to be added to the overall set of resources).

lib/ocf.ts

OCF Package

Classes

c
OCF(name: string)

The class representing the EPUB 3.4 OCF package.

lib/opf.ts

The OPF package

Classes

c
PackageWrapper(
identifier: string,
title: string
)

The OPF Wrapper

Interfaces

I
I
Package

Encoding of the XML structure of the package file in JSON; simply a wrapper around [[PackageContent]].

lib/overview.ts

Generate the Overview.xhtml entry

Functions

f
generate_overview_item(global: Global): ResourceRef[]

Generate the resource entry for the Overview.xhtml item into the package; that includes setting the various manifest item properties (see manifest item properties).

lib/title.ts

Title page

Functions

f
create_title_page(global: Global): ResourceRef[]

Create the cover page: it is an XHTML file with title, editors, copyright information, and a disclaimer whereby the EPUB version of the document is not authoritative.

lib/utils.ts

Some common utilities

Functions

f
date_to_string(date: string): string

Convert an ISO formatted date to a more readable format.

f
de_xml(inp: string): string

Remove any XML/HTML tags from the input; <br/> tags are replaced by space and all other tags are removed.

f
remove_entities(inp: string): string

Filter XML entities in an xhtml code, and turn them into their equivalent hexadecimal Unicode point

f
slice_text(inp: string): string

“Slice” a long text into lines separated by the (HTML) <br/> tag. Used as a rudimentary tool when adding the title lines to an SVG content.

f
to_xhtml(dom: jsdom.JSDOM | string): string

Convert an HTML5 content (in text or as a DOM) into XHTML5.