File: format_heuristics.py

package info (click to toggle)
pandoc-include 1.4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 448 kB
  • sloc: xml: 488; python: 456; ansic: 52; makefile: 17; cpp: 5
file content (62 lines) | stat: -rw-r--r-- 1,610 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import os

extensionFormats = {
    ".adoc"     : "asciidoc",
    ".asciidoc" : "asciidoc",
    ".context"  : "context",
    ".ctx"      : "context",
    ".db"       : "docbook",
    ".doc"      : "doc",
    ".docx"     : "docx",
    ".dokuwiki" : "dokuwiki",
    ".epub"     : "epub",
    ".fb2"      : "fb2",
    ".htm"      : "html",
    ".html"     : "html",
    ".icml"     : "icml",
    ".json"     : "json",
    ".latex"    : "latex",
    ".lhs"      : "markdown+lhs",
    ".ltx"      : "latex",
    ".markdown" : "markdown",
    ".mkdn"     : "markdown",
    ".mkd"      : "markdown",
    ".mdwn"     : "markdown",
    ".mdown"    : "markdown",
    ".Rmd"      : "markdown",
    ".md"       : "markdown",
    ".ms"       : "ms",
    ".muse"     : "muse",
    ".native"   : "native",
    ".odt"      : "odt",
    ".opml"     : "opml",
    ".org"      : "org",
    ".pdf"      : "pdf",
    ".pptx"     : "pptx",
    ".roff"     : "ms",
    ".rst"      : "rst",
    ".rtf"      : "rtf",
    ".s5"       : "s5",
    ".t2t"      : "t2t",
    ".tei"      : "tei",
    ".tei.xml"  : "tei",
    ".tex"      : "latex",
    ".texi"     : "texinfo",
    ".texinfo"  : "texinfo",
    ".text"     : "markdown",
    ".textile"  : "textile",
    ".txt"      : "markdown",
    ".wiki"     : "mediawiki",
    ".xhtml"    : "html",
    ".ipynb"    : "ipynb",
    ".csv"      : "csv",
    ".bib"      : "biblatex",
    ".xml"      : "xml",
    ".xslt"     : "xslt",
}

def formatFromPath(path: str):
    ext = os.path.splitext(path)[1]
    if ext in extensionFormats:
        return extensionFormats[ext]
    return None