Package edu.odu.cs.cowem.documents
Class MarkdownDocument
- java.lang.Object
-
- edu.odu.cs.cowem.documents.MarkdownDocument
-
-
Constructor Summary
Constructors Constructor Description MarkdownDocument(java.io.File input, WebsiteProject project0, java.util.Properties properties0)Create a document from the given file.MarkdownDocument(java.io.File fakeInputFile, WebsiteProject project0, java.util.Properties properties0, java.lang.String input)Create a document from the given string.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectgetMetadata(java.lang.String fieldName)Extracts a desired metadata field from the document.java.lang.StringgetModificationDate(java.io.File input)Estimate the date on which this document was last modified.java.lang.Stringpostprocess(org.w3c.dom.Document htmlDoc, java.lang.String format)Transform HTML to desired output format and apply late substitutions of properties and other special strings.java.lang.Stringpreprocess(java.lang.String format)Prepare for processing: Apply macros and extract metadata.org.w3c.dom.Documentprocess(java.lang.String markDownText)Convert Markdown text to an HTML structure.voidsetDebugMode(boolean mode)Turn indentation in generated XML on and off.java.lang.Stringtransform(java.lang.String format)Transform this document into a string suitable for writing into an HTML file.
-
-
-
Constructor Detail
-
MarkdownDocument
public MarkdownDocument(java.io.File input, WebsiteProject project0, java.util.Properties properties0)Create a document from the given file.- Parameters:
input- Markdown document textproject0- website project context,properties0- Properties to be used in processing this document.
-
MarkdownDocument
public MarkdownDocument(java.io.File fakeInputFile, WebsiteProject project0, java.util.Properties properties0, java.lang.String input)Create a document from the given string. "Pretend" that the input string was actually read from a file.- Parameters:
fakeInputFile- A path to a file that we will "pretend" is where the input string was obtainedproject0- project website contextproperties0- Properties to be used in processing this document.input- Markdown document text
-
-
Method Detail
-
transform
public final java.lang.String transform(java.lang.String format)
Transform this document into a string suitable for writing into an HTML file.
-
preprocess
public final java.lang.String preprocess(java.lang.String format)
Prepare for processing: Apply macros and extract metadata.- Parameters:
format- HTML format to be applied- Returns:
- A Markdown document string ready for conversion to HTML.
-
process
public final org.w3c.dom.Document process(java.lang.String markDownText)
Convert Markdown text to an HTML structure.- Parameters:
markDownText- document text in Markdown- Returns:
- DOM tree of generated HTML
-
postprocess
public final java.lang.String postprocess(org.w3c.dom.Document htmlDoc, java.lang.String format)Transform HTML to desired output format and apply late substitutions of properties and other special strings.- Parameters:
htmlDoc- the basic XML/HTML structure for the document.format- the desired format - used to select a stylesheet for the basic transformations.- Returns:
- transformed HTML string
-
getMetadata
public final java.lang.Object getMetadata(java.lang.String fieldName)
Extracts a desired metadata field from the document. Metadata fields are found at the start of a document in the form FieldName: value of field Metadata fields become part of the property set that is replaced in the document text as part of the post-processing, in which "@FieldName@" is replaced by the value of that property. Some metadata field names are inserted as part of early processing. These in include Title, Author, CSS, Date, Copyright, and JaxenURL.- Parameters:
fieldName- name of the metadata field- Returns:
- value of that metadata field extracted from the beginning of the document.
-
setDebugMode
public final void setDebugMode(boolean mode)
Turn indentation in generated XML on and off. Must be off in production to avoid distorting code listings.- Parameters:
mode- true iff debugging
-
getModificationDate
public java.lang.String getModificationDate(java.io.File input)
Estimate the date on which this document was last modified. 1. If the file is within a Git repository and unchanged, use the date of the last commit. 2. If the file is not within a Git repository or is changed, use the modification date of the file.- Parameters:
input- file to be checked- Returns:
- Data of last modification
-
-