Commit 68c2f30b authored by ankraft's avatar ankraft
Browse files

Initial version copied from the original repository

parent 45fac16d
Loading
Loading
Loading
Loading

LICENSE

0 → 100644
+29 −0
Original line number Original line Diff line number Diff line
BSD 3-Clause License

Copyright (c) 2022, Andreas Kraft
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
   contributors may be used to endorse or promote products derived from
   this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+27 −1
Original line number Original line Diff line number Diff line
TO BE ADDED
# onem2m-spec2md
 No newline at end of file

Convert oneM2M specification documents to markdown

## Installation

- Requirement: Python version >= 3.10
- Install the necessary packages with:
```
python3 -m pip install -r requirements.txt
```

## Usage
- Create a directory with the Word document in it. The Word document **must** be in *docx* format. This can be achieved by opening the document with *Word* and save it in *docx* format to another file.
- Create a configuration file with the same basename as the Word document + *.ini* extension. This file may contain different configurations as the standard *config.ini* file provided. 
  - Alternativaly, a file named *config.ini* will apply to all files in that directory.
  - It is only necessary to add the settings that are different from the *config.ini* file in the projects root directoy. That file will always act as a fallback.
- Run the converter as follows:
```
python3 spec2md.py <path-to-word-document>
```

## FAQ

### The converter doesn't seem to generate image files.

Is *LibreOffice* already running? If yes, then close it.

config.ini

0 → 100644
+107 −0
Original line number Original line Diff line number Diff line
#
#	config.ini
#
#	Default paragraph mappings for oneM2M specs to Markdown format
#
#	Note: all paragraph names must be in lower case.


[general]
replaceNbsp = &nbsp;

; Rename EMF/WMF image references to a different file extension.
; Allowed values: png, svg.
; If not preseent, no renaming will happen.
renameEMFExtension = svg

; Skip unrefereneced media files in conversion.
; Default: false
skipUnreferencedMediaFiles = false

replaceLt = &lt;

; Add image captions to the markdown's alternate text.
; Note, that the image caption has follow the image in the document.
imageCaptions2AltText = true

[toc]
addSectionNumbers = false
excludeFromNumbering =
tocStartParagraph = heading no numbering
tocHeaderLevel = 1
generateToc = false
addTocMacro = false


[paragraphs]
normal = normal
h1 = heading 1
h2 = heading 2
h3 = heading 3
h4 = heading 4
h5 = heading 5
h6 = heading 6
h7 = heading 7
a1 = heading 1
a2 = heading 2
a3 = heading 3
note = no
example = ex, ew
ul1 = b1, b1+, list paragraph
ul2 = b2, b2+
ul3 = b3, b3+
ul4 = b4, b4+
ul5 = b5, b5+
ol1 = bn
ol2 = bl
tablecaption = caption, th
imagecaption = tf
image = fl
empty = fp
ignore = toc 1, toc 2, toc 3, toc 4, toc 5, toc 6, toc 7


[characters]
; character value to replace with a character or string.
; The characters to be replaced and the characters that make the
; replacement string must be specified as hex values
; To remove a character from the file set it to 00 (2 zeros)

; "(c)"
a9 = 286329
; "(R)"
ae = 285229
; space
a0 = 20
; double quote
201c = 22
201d = 22
; single quote
2018 = 27
2019 = 27
; bullets
2022 = 2D20
b7 = 2a
; Dashes
2013 = 2d
; Full-size comma
ff0c = 2c20
; "<="
2264 = 3c3d
; ">="
2265 = 3e3d
; "..."
2026 = 2e2e2e
; um
339b = 756d
; "x"
d7 = 78
; Ligature "fi"
fb01 = 6669


[media]
; The following configurations specifies the cli command to convert a single .emf file to the.png and .svg image formats.
; If no conversion should or can be done, remove or comment the lines.
emfConverterPng = /Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to png "{infile}" --outdir "{outdir}"
emfConverterSvg = /Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to svg "{infile}" --outdir "{outdir}"

requirements.txt

0 → 100644
+16 −0
Original line number Original line Diff line number Diff line
#
# This file is autogenerated by pip-compile with python 3.10
# To update, run:
#
#    pip-compile
#
commonmark==0.9.1
    # via rich
lxml==4.9.1
    # via python-docx
pygments==2.13.0
    # via rich
python-docx==0.8.11
    # via oneM2M-spec-2-MD-converter (setup.py)
rich==12.5.1
    # via oneM2M-spec-2-MD-converter (setup.py)

setup.py

0 → 100644
+15 −0
Original line number Original line Diff line number Diff line
from setuptools import setup, find_packages

setup(
	name='oneM2M spec-2-MD converter',
	version='0.0.1',
	url='https://git.onem2m.org/tools/spec2md',
	author='Andreas Kraft',
	author_email='an.kraft@gmail.com',
	description='Convert oneM2M specifications to Markdown',
	packages=find_packages(),
	install_requires=[
		'rich',
		'python-docx',
	 ]
)
Loading