These function can be used to convert one or more parsed sources to HTML, or to convert all sources to tabbed sections in Markdown.

export_to_html(
  input,
  output = NULL,
  template = "default",
  fragment = FALSE,
  preventOverwriting = rock::opts$get(preventOverwriting),
  encoding = rock::opts$get(encoding),
  silent = rock::opts$get(silent)
)

export_to_markdown(
  input,
  heading = "Sources",
  headingLevel = 2,
  template = "default",
  silent = rock::opts$get(silent)
)

Arguments

input

An object of class rock_parsedSource (as resulting from a call to parse_source) or of class rock_parsedSources (as resulting from a call to parse_sources.

output

For export_to_html, either NULL to not write any files, or, if input is a single rock_parsedSource, the filename to write to, and if input is a rock_parsedSources object, the path to write to. This path will be created with a warning if it does not exist.

template

The template to load; either the name of one of the ROCK templates (currently, only 'default' is available), or the path and filename of a CSS file.

fragment

Whether to include the CSS and HTML tags (FALSE) or just return the fragment(s) with the source(s) (TRUE).

preventOverwriting

For export_to_html, whether to prevent overwriting of output files.

encoding

For export_to_html, the encoding to use when writing the exported source(s).

silent

Whether to suppress messages.

heading, headingLevel

For

Value

A character vector or a list of character vectors.

Examples

### Get path to example source
examplePath <-
  system.file("extdata", package="rock");

### Parse a selection of example sources in that directory
parsedExamples <- rock::parse_sources(
  examplePath,
  regex = "(test|example)(.txt|.rock)"
);

### Export results to a temporary directory
tmpDir <- tempdir(check = TRUE);
prettySources <-
  export_to_html(input = parsedExamples,
                 output = tmpDir);

### Show first one
print(prettySources[[1]]);
#> [1] "\n<html><head>\n\n<style>\n\n\n.code {\n  border-radius: .25em;\n  box-sizing: border-box;\n  margin-left: 10px;\n  padding: 2px;\n}\n\n.codeValue {\n  border-radius: .25em;\n  box-sizing: border-box;\n  margin-left: 10px;\n  padding: 2px;\n}\n\n.identifier {\n  border-radius: .25em;\n  box-sizing: border-box;\n  margin-left: 10px;\n  padding: 2px;\n}\n\n.sectionBreak {\n  border-radius: .25em;\n  box-sizing: border-box;\n  display: block;\n}\n\n.uid {\n  border-radius: 0;\n  box-sizing: border-box;\n}\n\n.utterance {\n  display: block;\n}\n\n.code {\n  background-color: #f4d142;\n}\n\n.codeValue {\n  background-color: #d2af20;\n}\n\n.identifier {\n  background-color: #aaaaff;\n}\n\n.sectionBreak {\n  background-color: #eeeeff;\n}\n\n.uid {\n  background-color: #eeeeee;\n  color: #bbbbbb;\n}\n\n.utterance {\n  border-top: 1px dotted black;\n  border-bottom: 1px dotted black;\n}\n\n.utterance + .utterance {\n  margin-top: -1px;\n}\n\n.context {\n  color: #bbbbbb;\n}\n</style>\n\n</head><body>\n<div class='utterance'><div class=\"utterance\">This file is a very drafty file used to test stuff. It contains some meeting minutes and some other stuff.</div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">The contents aren't relevant; it's all about the parsing of the ROCK conventions.</div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">Coding tree specifications:</div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">  Coding trees are by definition hierarchical: there is a root with children (potentially with children of their own, and so on, with arbitrary depth). Every node in such a tree has at least an identifier, which can contain only lowercase letters, nummers, and underscores. In addition, it can have a label, which can be anything and is the human-readable name, and a code which is used to code the utterances. If a label or code is not specified, the identitier is used (for example, if the identifiers are suitable for coding, it will often not be necessary to specify both identifiers and codes; but it is possible to enable use of DCT identifiers as identifier while using codes that are more practical). Nodes can optionally have one or more children. Since only the identifier is mandatory (and copied to codes and labels if those are omitted), children can be specified using a shorthand using a list of identifiers contained between square brackets and separated by comma's.</div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">Stanzas are not necessarily higher-level codes.</div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">Stanzas are sets of utterances within which you want to look for code co-occurrence.</div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">People's narratives convey information about their psychology. In their narratives,</div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">Co-occurrences</div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">Utterances  Sections  Stanzas  StanzaType  Strophes</div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">---------------------------------------------------</div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">1           1         1        A           1</div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">2           1         1        A           1</div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">3           1         2        B           2</div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">4           1         3        A           1</div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">5           2         3        A           1</div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">Utterance = smallest unit of analysis, usually one sentence, in any case, one line (a line being defined as a set of characters ending with a line ending)</div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">Section = a set of one or more utterances that follow each other and fall between the same two section markers ('nongreedy')</div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">Stanza = a set of one or more utterances that occur in close proximity and that are defined by ... (the complicated bit), i.e. the smallest unit of analysis psychologically. Stanzas are a solution for the fact that peoples' sentence length is not closely related to the psychological unity of the matter they discuss. E.g. Alice could discuss her ideas about the cause of the disease in three sentences while Bob would use only one, but both explanations would be the same stanza. Stanzas are what in written text would be paragraphs. Except that spoken text is more messy, and so 'paragraphs' can be interspersed by unrelated utterances. Therefore, utterances in close proximity can be combined into the same stanza even if they are separated by a small number of unrelated utterances. Note, however, that stanzas remain defined as 'messy paragraphs'; if an interviewee starts referring back to something discussed half an hour earlier, that doesn't justify combining those utterances into the same stanza. (Note, however, that they _could_ be combined through stanza sets / strophes, if they happen to be codes by the same codes, _and_ if strophes are composed by collapsing stanzas with those codes.)</div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">Strophe = a set of one or more stanzas that are combined based on sharing the same code, identifier, or attribute. Strophes, therefore, are collected over the entire transcript/source or over all transcripts/sources; proximity is irrelevant.</div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">Conversation = a transcript = a source</div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">Case = a person (assuming persons are the research unit, could in theory also be an organisation etc)</div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">Attribute = a characteristic of a case (that can then be designated to utterances as well)</div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">Unit = a set of one or more utterances that share a given attribute</div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">Discourse = all utterances</div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">Topic = a subject area discussed in the interview - i.e. topics are known beforehand and together form the interview scheme / questionnaire / whatever</div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"><span class=\"identifier caseId\">[[cid=1]]</span></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"><span class=\"sectionBreak sectionBreak\">---&lt;&lt;paragraph_break&gt;&gt;---</span></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">Why did you do that? <span class=\"code codes\">[[Topic1]]</span> <span class=\"identifier caseId\">[[cid=1]]</span> [[tid=1]]</div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"><span class=\"sectionBreak sectionBreak\">---&lt;&lt;B&gt;&gt;---</span></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"><span class=\"sectionBreak sectionBreak\">---&lt;&lt;A&gt;&gt;---</span></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. <span class=\"code codes\">[[inductMother&gt;inducChild1]]</span> <span class=\"identifier caseId\">[[cid=1]]</span></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.<span class=\"code codes\">[[inductFather&gt;inducChild3]]</span> <span class=\"identifier caseId\">[[cid=1]]</span></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. <span class=\"code codes\">[[inductMother&gt;inducChild2]]</span> <span class=\"identifier caseId\">[[cid=1]]</span></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">Why do we use it? <span class=\"code codes\">[[inductMother&gt;inducChild1]]</span>  <span class=\"identifier caseId\">[[cid=1]]</span></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. <span class=\"code codes\">[[inductFather&gt;inducChild4]]</span> <span class=\"identifier caseId\">[[cid=1]]</span></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"><span class=\"sectionBreak sectionBreak\">---&lt;&lt;A&gt;&gt;---</span></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. <span class=\"identifier caseId\">[[cid=1]]</span></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. <span class=\"code codes\">[[inductFather&gt;inducChild3]]</span> <span class=\"identifier caseId\">[[cid=1]]</span></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"><span class=\"sectionBreak sectionBreak\">---&lt;&lt;A&gt;&gt;---</span></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"><span class=\"sectionBreak sectionBreak\">---&lt;&lt;B&gt;&gt;---</span></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">Where does it come from? <span class=\"code codes\">[[inductFather&gt;inducChild4]]</span> <span class=\"identifier caseId\">[[cid=1]]</span></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">Contrary to popular belief, Lorem Ipsum is not simply random text. <span class=\"code codes\">[[inductFather&gt;inducChild5]]</span> <span class=\"identifier caseId\">[[cid=1]]</span></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"><span class=\"sectionBreak sectionBreak\">---&lt;&lt;paragraph_break&gt;&gt;---</span></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. <span class=\"code codes\">[[Topic2]]</span> <span class=\"identifier caseId\">[[cid=1]]</span> [[tid=2]]</div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. <span class=\"code codes\">[[tables]]</span> <span class=\"code codes\">[[people]]</span> <span class=\"identifier caseId\">[[cid=1]]</span></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of \"de Finibus Bonorum et Malorum\" (The Extremes of Good and Evil) by Cicero, written in 45 BC. <span class=\"code codes\">[[oaken_chests]]</span> <span class=\"code codes\">[[people]]</span> <span class=\"identifier caseId\">[[cid=1]]</span></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">This book is a treatise on the theory of ethics, very popular during the Renaissance. <span class=\"code codes\">[[people]]</span> <span class=\"identifier caseId\">[[cid=1]]</span></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">The first line of Lorem Ipsum, \"Lorem ipsum dolor sit amet..\", comes from a line in section 1.10.32. <span class=\"identifier caseId\">[[cid=1]]</span></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"><span class=\"sectionBreak sectionBreak\">---&lt;&lt;A&gt;&gt;---</span></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from \"de Finibus Bonorum et Malorum\" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.</div>\n</div>\n\n<div class='utterance'><div class=\"utterance\"></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">Where can I get some? <span class=\"code codes\">[[inductFather&gt;inducChild3]]</span></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. <span class=\"code codes\">[[chairs]]</span> <span class=\"code codes\">[[internet]]</span></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. <span class=\"code codes\">[[inductFather&gt;inducChild3]]</span></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. <span class=\"code codes\">[[internet]]</span></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. <span class=\"code codes\">[[inductFather&gt;inducChild4]]</span> <span class=\"code codes\">[[inductMother&gt;inducChild1]]</span></div>\n</div>\n\n<div class='utterance'><div class=\"utterance\">The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc. <span class=\"code codes\">[[tables]]</span> <span class=\"code codes\">[[att_ins_eval]]</span></div>\n</div>\n\n</body></html>\n"