XDXF to HTML conversion
Project description
Description
This is a Python module that converts XDXF formatted dictionary texts into HTML, written in modern C++.
It depends on nothing except for a C++11-compliant compiler. The parser does no error checking to minimise overhead.
Installation
pip install xdxf2html
Building
python3 setup.py build
Usage
>>> import xdxf2html
>>> xdxf2html.convert('''<k>Liverpool</k>
... <blockquote><dtrn>a large city and port in north-west England, on the River Mersey. It first became important during the <kref>Industrial Revolution</kref>, producing and exporting cotton goods. It was also a major port for the slave trade, receiving profits from the sale of slaves in America. In the 20th century the city became famous as the home of the <kref>Beatles</kref> and for Liverpool and Everton football clubs. Among its many famous buildings are the Royal Liver Building with its two towers, the Anglican and Roman Catholic cathedrals, and the <kref>Walker Art Gallery</kref>.</dtrn> <rref>portlpool.jpg</rref></blockquote>
... <blockquote>See also <kref>Mersey beat</kref>.</blockquote>''', 'test_dict')
'<h3 class="headword">Liverpool</h3><div class="xdxf-definition" style="margin-left: 0em;">a large city and port in north-west England, on the River Mersey. It first became important during the <a href="/api/lookup/test_dict/Industrial Revolution">Industrial Revolution</a>, producing and exporting cotton goods. It was also a major port for the slave trade, receiving profits from the sale of slaves in America. In the 20th century the city became famous as the home of the <a href="/api/lookup/test_dict/Beatles">Beatles</a>and for Liverpool and Everton football clubs. Among its many famous buildings are the Royal Liver Building with its two towers, the Anglican and Roman Catholic cathedrals, and the <a href="/api/lookup/test_dict/Walker Art Gallery">Walker Art Gallery</a>.<img src="/api/cache/test_dict/portlpool.jpg" alt="portlpool.jpg"/></div><div class="xdxf-definition" style="margin-left: 0em;">See also <a href="/api/lookup/test_dict/Mersey beat">Mersey beat</a>.</div>'
The module has only one method: convert
, which takes two arguments: the XDXF text and the name of the dictionary. It returns the HTML text.
Appendix: a hopefully complete listing of XDXF tags, both standard and non-standard
This section will only include tags found within the dictionary 'body', i.e. <lexicon>
.
Representational tags
<b>
,<i>
,<u>
,<sub>
,<sup>
,<tt>
,<br>
: Could be directly translated into HTML.<c>
: Colour, indicated by the attributec
. Converted to a<span>
with the stylecolor: c
. The default colour isdarkgreen
.
<div>
like tags
<ar>
: Article, ignored in this project.<def>
: Definition, converted to a<div>
with the classxdxf-definition
. If the attributecmt
is present, write it as a<span>
with the classcomment
inside the<div>
; if the attributefreq
is present, write it as a<span>
with the classfrequency
inside the<div>
.<ex>
: Example, converted to a<div>
with the classexample
and the stylemargin-left: 1em; color: grey;
.<co>
: Comment, converted to a<div>
with the classcomment
.<sr>
: 'Semantic relations', converted to a<div>
with the classsemantic-relations
.<etm>
: Etymology, converted to a<div>
with the stylecolor: grey;
.<blockquote>
: Not in the specification, but I've seen it. Converted to a<p>
.
<span>
like tags
<k>
: Keyword, namely the headword, converted to an<h3>
with the classheadword
.<opt>
: Optional part of the keyword, converted to a<span>
with the classoptional
.<deftext>
: Definition text, ignored in this project.<gr>
: Grammatical information, converted to a<span>
with the stylefont-style: italic; color: darkgreen;
.<pos>
,<tense>
: Ignored.<tr>
: Transcription, converted to a<span>
with the classtranscription
.<kref>
: Keyword reference, converted to an<a>
with thehref
attribute properly set (in this project, to/api/lookup/name of dictionary/keyword
). If the attributetype
is set, prepend the value of the attribute to the keyword with a colon and a space.<iref>
: External reference, could be directly converted to an<a>
.<dtrn>
: Definition translation, in practice used as an equivalent of<def>
. So we'd better ignore it.<abbr>
,<abr>
: Abbreviation, converted to a<span>
with the classabbreviation
and the stylecolor: darkgreen; font-style: italic;
.<ex_orig>
,<ex_trn>
: Example original and translation, converted to a<span>
with the classexample-original
andexample-translation
respectively.<exm>
,<prv>
,<oth>
: Used inside<ex>
, ignored in this project.<mrkd>
: Marked text, converted to a<span>
with the stylebackground-color: yellow;
.<nu>
: Not-used, not explained in the specification. Ignored in this project.<di>
: 'Don't index', ignored in this project.<syn>, <ant>, <hpr>, <hpn>, <par>, <spv>, <mer>, <hol>, <ent>, <rel>, <phr>
: Phrasemes (don't know really what they are).<syn>
and<ant>
are converted to<span>
with the classsynonym
andantonym
respectively, and the tag name is prepended to the text content with:
. The rest are ignored.<categ>
: Category, ignored in this project.
Media files
Always in an <rref>
tag. The standard prescribes that the filename should be specified in the lctn
attribute, but in practice, the filename is just the text child of the tag. Converted to <img>
, <audio>
, <video>
or <a>
depending on the file extension.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for xdxf2html-0.1.0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f55347f615c7f4dd65bde131b7382915766aa26b4ed4dc606dbe1e34fb8978b9 |
|
MD5 | 4d4c9d2784f4977fcb82e8c6aea80de8 |
|
BLAKE2b-256 | 7f0ee83bbf43fa1ce9bcf52de992754a11f3076ba01545f328019d6627acfea6 |
Hashes for xdxf2html-0.1.0-cp312-cp312-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9aa9896b5e1af9d1b22c5b588e7d62a0310a3d7c18ca7bb9f3b7aef9e651be9 |
|
MD5 | 3751f99c3d07d517231af8695dd5b3d9 |
|
BLAKE2b-256 | 069e67667f81823ed4510e134b75f51917e42e00d85787a0ff2626bddbe6d067 |
Hashes for xdxf2html-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d219bea1f50906d3608a4890a88bb132fac4f9cae7b501fa9a28d97c1b0ae525 |
|
MD5 | 585f9a79775ac659cd10b36ea88c8fd9 |
|
BLAKE2b-256 | 40bdb02227d58be9ce3e03e0861d659a5b450c7e7af4a0f587c18d3230f87a2f |
Hashes for xdxf2html-0.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa65479608078bcf291708229abe8c695e7ec8b59488bdcd927d90512e75685d |
|
MD5 | 537d76da9a09a5df34c4301abe16b7f7 |
|
BLAKE2b-256 | 428b2432a62e9064291585575030f05431115070a31bbba14329130288d192ba |
Hashes for xdxf2html-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42e8860d2156f0db0c2468cf053c3dc47e06006e84fa40f748438c7482735690 |
|
MD5 | 3c6d3f6d3e7df06bedf4359b0234a3cb |
|
BLAKE2b-256 | 7d2d5a0bbdaa9eabadf1dd79bdb26420592dcc6f6cd5cbd55e9b66b683f37538 |
Hashes for xdxf2html-0.1.0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4fe3d4f6092447e2259a24a47a8ec1bf9c0cc88614ac8e2eb9cb7d232b6c1ad6 |
|
MD5 | 3663a7c8ed61e28764ac8a1cef3e6004 |
|
BLAKE2b-256 | 1c33188d4a5c183d329d10ed55cb154dffe87b356f53e0c12d6bd65fd6b0d820 |
Hashes for xdxf2html-0.1.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6326715db4262ce9e0a6f53133cd8548407e0f6a9a15314a52db60212b67cfea |
|
MD5 | cee55460d4e9c73706042fc26657cee8 |
|
BLAKE2b-256 | 51c3fec5272dcf3c70ba44db935078b3b2b10a176fdf4aeba4edd7ebbb10d203 |
Hashes for xdxf2html-0.1.0-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55cecbffb701b8301219604a96233ffc00372c71057a9aa629800e8d25dfd095 |
|
MD5 | 9dd84e9bf6dd7463687327a03891a4c7 |
|
BLAKE2b-256 | 09293abcafafef11bf738070d57d157c2915c1fd3d16cd97ca6a49f4786b2daf |
Hashes for xdxf2html-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f595f3d3799df57ad3cdb518cc99b3ab4e21cc47480aa60b3901585f8c7c224f |
|
MD5 | e2e597fedafb861414f9e24e7ce58f54 |
|
BLAKE2b-256 | 7297bd9de60ee714284b0ef1ef806ebedd6183053cb6ee7e1e5badd56cff4851 |
Hashes for xdxf2html-0.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 488dadd4271d511b7cebfe2e2f090dcb09392cba73cddcb76e79317943736b57 |
|
MD5 | c4d2956f74da87248a6f3d8d89f67882 |
|
BLAKE2b-256 | c425d28c7d9e52e902118567fe35089d5d25fc33dd3466dba1bf3099d0427399 |
Hashes for xdxf2html-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca6c2aaf48321a8ae14da4aaf49cee6c1a77fe565ee7c4966842eef1f14cf2d4 |
|
MD5 | 1595e1294817dec331ff4f4869e7127f |
|
BLAKE2b-256 | 50b21f12e8216ad683568473781d60aa4b6b5ed923bf74115d63fdf476983784 |
Hashes for xdxf2html-0.1.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 153f3068eb8a83df927a8f13b900c83a7fa8eb2427951a3f58a9c86bd36fb904 |
|
MD5 | c348873e709a06ca73b863da2bb1de4e |
|
BLAKE2b-256 | 9357e9c31905547e90dd1509dbbfba9e093a9ff18d8cd6d793c24e0e9d593fd2 |
Hashes for xdxf2html-0.1.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb802be5a14b450282fbe625de9b80ea7d8cf3e50fc4007cb86de5e40e591579 |
|
MD5 | 9b190f3bdb518188eb658737aa134739 |
|
BLAKE2b-256 | 5cdcb7f9710fdefc6fdd7e982a2447ef66b9aa0b6fb3f2ca7eed80e64e730256 |
Hashes for xdxf2html-0.1.0-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9998e7f7aabc74612a8817024f159a0120f22cc7a1ddc1ad14d94be8d7a61402 |
|
MD5 | fecedd9bea32a5fa04b70e11db4792f8 |
|
BLAKE2b-256 | 87d9181cba90357e152f9aeeda1a6e01371650a3575fec5c316bcb150b4aadc6 |
Hashes for xdxf2html-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7cb34f553013dc7e04ca2d277e9f4507f3836f5018a3d3e3ecc7668d4ef79c54 |
|
MD5 | 4fe16a48df242c1cf5264b25332ea67b |
|
BLAKE2b-256 | 431575456f9f5af5cf7717a0368a95f35153f5a6f19be31c6e7cefab4c0746cb |
Hashes for xdxf2html-0.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d0bb02f71a265d00e4345d3e3368711d89c19c066e361e2530823e14b3436b6 |
|
MD5 | 5670aa43c3ca57120f12a616d83073f6 |
|
BLAKE2b-256 | 205bd7c3c016e244c087061b7060dfd62cc81d613dabba66a4208ca22dc65e2b |
Hashes for xdxf2html-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03dc1eb518cc950e13d14c0f23fc00c9c6d04d5932f607115eea53531941fcc7 |
|
MD5 | fb5087bd5a9313e7b6c44f75ee9dd4fb |
|
BLAKE2b-256 | a337170f05ce7fb0249066bb88014f832a9f7ecffa5ba5834be764b67ac2370f |
Hashes for xdxf2html-0.1.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b2786b40d881c1e25019cd47d4f92969540d5da650f398275e4896f0cc36940 |
|
MD5 | c44a9c8e465710371eccb92233d88708 |
|
BLAKE2b-256 | 537d59200e95514740fba25670e9bd20059fb6f64f263298a0df27b6b8a0cc03 |
Hashes for xdxf2html-0.1.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73c3df9b7cb417f4900d8076d64f2d855e3761b003bafbee006456773ea933ae |
|
MD5 | 6894327a40f9724ac8bc93b157b0bec0 |
|
BLAKE2b-256 | 3059cbfb8bb8bb8a6dd3f78426de99181e439d232408fdfec93884a7fda1a965 |
Hashes for xdxf2html-0.1.0-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37de8206854498301cd4b91aeeac7c045ce048c307165819ce5f01c6dad14a5f |
|
MD5 | 5c68cd6f3cbdca567b3959a0e95c849d |
|
BLAKE2b-256 | 057195c132411f7aa637d74655ec1715fa65d6cc6a518afd4903ff764b3e8e5a |
Hashes for xdxf2html-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de54d05bfe3e23bcd4a31b055980217a4efd5de95d6565a6dcf2f455320ea02f |
|
MD5 | d7f2d6a4594d74840a0c9f5c4b7e0374 |
|
BLAKE2b-256 | 16b594cc4bd81031eda463f4f2a25f732300265bbbf488c06137ad6653cd0873 |
Hashes for xdxf2html-0.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5fe71f9953c5bd45d68797fbc5d4030ab8c34a0bc03d214b842b12abc632cfd9 |
|
MD5 | 07e0b7d1b6448ef2f8c956f47c4194a4 |
|
BLAKE2b-256 | 19a4b0a1ea1bf60902baaf1ffba8edf82993a8f12ec8817dda25535ecfa34e17 |
Hashes for xdxf2html-0.1.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ed0ae55d46f5ab9c73c2cdf322fd669a0c3fcb1246123b7ebceadc911b94210 |
|
MD5 | 545c3c7e4ae49e285042f088c48a38a4 |
|
BLAKE2b-256 | b9adadd458c67df29bd6ac09881d3e4ba1ca6c19bb0492305f9894840273206e |
Hashes for xdxf2html-0.1.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d5c334b5b709f76170dd94490e8826c3ce8eac0a2bd4a5e09d533c9d02e308a |
|
MD5 | 09836649cdd84d40b240c4e959e885ed |
|
BLAKE2b-256 | 0becb1e6b7d9b4c085ec91d36a50a73dc0da4614f92c8985c39c9b58a3dab6bb |
Hashes for xdxf2html-0.1.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4f218ec5db18e98f7ab3da6a50455744e0c89a519977bb20d7db237ab68a28e |
|
MD5 | 5f965370f8ff8db8844d1f275fbde985 |
|
BLAKE2b-256 | 586595c2a660b5e8ca9062cfd9eb659a08a7eed91c6191894203171f06afd0db |
Hashes for xdxf2html-0.1.0-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0a5808a9611452540fc485b8de1e810ffc8216d61f877625531371430aaea84 |
|
MD5 | 0a22f10ac2113576109cf9ffaffb3397 |
|
BLAKE2b-256 | a3060c453790aa3544db4cdf3219f445972a98fb019bc0864930bd67b07ccf82 |
Hashes for xdxf2html-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d61eb21b11c48a2f64617159bfabfe6b5c45040d0a489f36d9ec64ccfe19a5a |
|
MD5 | 5da6b967695d38d961ab427e3124494e |
|
BLAKE2b-256 | 94f8dd34377c47481ef1ee04f06b42cdafc82ab2d2c24bd7594b27a9a2e5c476 |
Hashes for xdxf2html-0.1.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7a1ffdd60f703e0ea5971487a0455fba5719d8a25521c22e30aa69755331797 |
|
MD5 | 46e646f5bbf73ebf035d9c83c54b1970 |
|
BLAKE2b-256 | a67298a71f92bcca34147a9c5d3a37d860f829e3fe0fa3bb64b026d2cb1c1e75 |
Hashes for xdxf2html-0.1.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b08fc016dc8fcfb20c6620239555c441893f9d323450a7eaa24e7fb88bd0236 |
|
MD5 | ef8a3e69a9596db994e77ea5ce293203 |
|
BLAKE2b-256 | e499fddb4caf4207524800521c0b46052c6b5b877acf58d2a7ead3896106b921 |
Hashes for xdxf2html-0.1.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1dcd5bfe9d11595658afe38a14429b25ed096215225c54c3f0f4dc48ffe380b3 |
|
MD5 | 7b5a8538091abd980689e4b8877e8c18 |
|
BLAKE2b-256 | 204cb57d5adead34889ae9dbb60f4bc1e24c4ed4c367867b78f307a47c88c0cd |
Hashes for xdxf2html-0.1.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 370a82858c7de7481ec718e9333aec288bd28b32ddef7befe3cf6ddbd4c62bea |
|
MD5 | 08c205c1d590e831b9cadfcb6c97b8a6 |
|
BLAKE2b-256 | e90336aaf6491054eb8bdc5b812d8e0dad37c9ce2d3dee9d66b3562cf9c1eae1 |
Hashes for xdxf2html-0.1.0-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28ccaed2ce05f662688307c5b89647778f7bd6e193cae4deb3a7bfffce542477 |
|
MD5 | a12a349a4b1a019d1dd3e46571b1193a |
|
BLAKE2b-256 | e21b8472782b0a7030a0ee901574b10c0f198a43c9e250c569d8268e3e60d7ed |
Hashes for xdxf2html-0.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 259b84c7f220b8810d1be143b30f037938a7b70eed592e2088cee3c1e084ba21 |
|
MD5 | f380fda81b29d3ff2341c08dbe65783b |
|
BLAKE2b-256 | 28bedc60d40b6a58d87aeea643d34116d0214f6eea2de7bb8cd06e70122d9ac7 |
Hashes for xdxf2html-0.1.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be10ab82b38769ed7c8bb1871dc05b8bd78a7037243ab03f6e63a22c103193fd |
|
MD5 | 696991181d9a728f6bb32a6a79593f56 |
|
BLAKE2b-256 | cd058e34717da47144057f917c958e46d797d9aedbeddc810a82b5395b1ea7a2 |
Hashes for xdxf2html-0.1.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba2886123d6b288e76409ee98ac812a33a8fa3d45f16eb6be6564f0d4d81c90b |
|
MD5 | ab1b5202a65f3abab313a6ad3ee9da48 |
|
BLAKE2b-256 | d7e4b0d475dbadc99508b2d3e90567f25445526f64fe502c0a57759d7980885b |