Title: | Read InDesign Markup Language (IDML) Files |
---|---|
Description: | Read InDesign Markup Language (IDML) Files into R. Additional functions to modify and write IDML files may be added in the future. |
Authors: | Eli Pousson [aut, cre, cph] |
Maintainer: | Eli Pousson <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0 |
Built: | 2024-10-31 05:35:53 UTC |
Source: | https://github.com/elipousson/idmlr |
new_idml()
creates a idml class object from a file path and contents.
validate_idml()
checks idml objects. Used by read_idml()
to create idml
objects from a file and by other functions to validate input idml objects.
new_idml(file, path, contents, error_call = caller_env()) validate_idml( idml, what = "idml", nm = c("file", "path", "contents"), type = "application/vnd.adobe.indesign-idml-package", arg = caller_arg(idml), error_call = caller_env() )
new_idml(file, path, contents, error_call = caller_env()) validate_idml( idml, what = "idml", nm = c("file", "path", "contents"), type = "application/vnd.adobe.indesign-idml-package", arg = caller_arg(idml), error_call = caller_env() )
file |
File name for input IDML file. |
path |
Path to location of unzipped IDML file. This is the directory where the XML files are located. |
contents |
A named list of |
error_call |
The execution environment of a currently
running function, e.g. |
idml |
An |
type |
MIMETYPE value to use in validating |
arg |
An argument name as a string. This argument will be mentioned in error messages as the input that is at the origin of a problem. |
get_idml_contents()
is a helper for extracting or converting xml_document
objects from the idml
list object.
get_idml_contents( idml, dir = NULL, file = NULL, format = "xml_document", ns = character(), parent_nm = NULL, unique_nm = TRUE, type = "attr", ..., error_call = caller_env() ) format_idml_content( content, format = "xml_document", ns = character(), parent_nm = NULL, unique_nm = TRUE, type = "attr", names_to = zap(), allow_list = TRUE, ..., error_call = caller_env() )
get_idml_contents( idml, dir = NULL, file = NULL, format = "xml_document", ns = character(), parent_nm = NULL, unique_nm = TRUE, type = "attr", ..., error_call = caller_env() ) format_idml_content( content, format = "xml_document", ns = character(), parent_nm = NULL, unique_nm = TRUE, type = "attr", names_to = zap(), allow_list = TRUE, ..., error_call = caller_env() )
idml |
A |
dir , file
|
Directory and file name from IDML contents to return. If
|
format |
"list", "xml_document", or "data.frame". If "list", contents
are converted with |
ns |
Optionally, a named vector giving prefix-url pairs, as produced
by |
parent_nm |
Name of top-level parent node. If parent_nm is a
character vector, |
unique_nm |
If |
type |
Type of data to extract from chlildren nodes: "attr" (attributes) or "text". |
... |
Needed for compatibility with generic. Unused. |
error_call |
The execution environment of a currently
running function, e.g. |
A list, XML document, data frame, or data frame list depending on format and the input idml object.
idml_list_stories()
lists stories and related elements from a idml object.
idml_list_story_paras()
returns just the ParagraphStyleRange element of the
stories.
idml_list_stories(idml, format = "contents") idml_list_story_paras(idml, ...)
idml_list_stories(idml, format = "contents") idml_list_story_paras(idml, ...)
idml |
An |
format |
Format of output to return. Must be "contents" |
A bare named list with four elements: Stories, StoryPreference, InCopyExportOption, and ParagraphStyleRange.
## Not run: if(interactive()){ path <- system.file("idml/letter_portrait_standard.idml", package = "idmlr") idml_obj <- read_idml(path) idml_list_stories(idml_obj) } ## End(Not run)
## Not run: if(interactive()){ path <- system.file("idml/letter_portrait_standard.idml", package = "idmlr") idml_obj <- read_idml(path) idml_list_stories(idml_obj) } ## End(Not run)
idml_list_styles()
takes an idml object and returns a bare list with names,
properties, attributes, and content from the XML nodes definition the
paragraph, character, or other styles of the specified type.
idml_list_styles(..., type = "paragraph", format = "list")
idml_list_styles(..., type = "paragraph", format = "list")
... |
Arguments passed on to
|
type |
Type of data to extract from chlildren nodes: "attr" (attributes) or "text". |
format |
Output format must be "list" |
A bare list with four elements: a named list of style attributes (names are style names), properties for the style XML nodes, attributes for the style XML nodes, and the contents of each XML node.
## Not run: if(interactive()){ path <- system.file("idml/letter_portrait_standard.idml", package = "idmlr") idml_obj <- read_idml(path) idml_list_styles(idml_obj) } ## End(Not run)
## Not run: if(interactive()){ path <- system.file("idml/letter_portrait_standard.idml", package = "idmlr") idml_obj <- read_idml(path) idml_list_styles(idml_obj) } ## End(Not run)
Get metadata from an IDML object
get_idml_meta()
extracts a metadata elements from an idml
object in the
supplied format.
get_idml_meta(idml, format = "xml_document", ..., error_call = caller_env())
get_idml_meta(idml, format = "xml_document", ..., error_call = caller_env())
idml |
A |
format |
"list", "xml_document", or "data.frame". If "list", contents
are converted with |
... |
Arguments passed on to
|
error_call |
The execution environment of a currently
running function, e.g. |
By default, if format = "data.frame"
, get_idml_fonts()
returns a single
data.frame and get_idml_styles()
, get_idml_graphic()
, and
get_idml_preferences()
returns a list of data.frame objects values present
in the input idml
object. This format option is still under development and
does not return all available data from the xml_document
. Note, for the
get_idml_styles()
, the parent_nm
argument is ignored and may be removed.
get_idml_resource( idml, resource, format = "xml_document", ..., error_call = caller_env() ) get_idml_fonts(idml, format = "xml_document", parent_nm = NULL, ...) get_idml_styles( idml, format = "xml_document", type = NULL, parent_nm = NULL, ... ) get_idml_graphic(idml, format = "xml_document", parent_nm = NULL, ...) get_idml_preferences(idml, format = "xml_document", parent_nm = NULL, ...)
get_idml_resource( idml, resource, format = "xml_document", ..., error_call = caller_env() ) get_idml_fonts(idml, format = "xml_document", parent_nm = NULL, ...) get_idml_styles( idml, format = "xml_document", type = NULL, parent_nm = NULL, ... ) get_idml_graphic(idml, format = "xml_document", parent_nm = NULL, ...) get_idml_preferences(idml, format = "xml_document", parent_nm = NULL, ...)
idml |
A |
resource |
One or more resource names: "Graphic.xml", "Fonts.xml", or "Styles.xml" |
format |
"list", "xml_document", or "data.frame". If "list", contents
are converted with |
... |
Arguments passed on to
|
error_call |
The execution environment of a currently
running function, e.g. |
parent_nm |
Name of top-level parent node. If parent_nm is a
character vector, |
type |
Type of data to extract from chlildren nodes: "attr" (attributes) or "text". |
Get spreads from an IDML object
get_idml_spreads()
extracts a list of xml documents for spreads or a data
frame from a idml
object.
get_idml_spreads( idml, format = "list", names_to = "Spread", ..., error_call = caller_env() )
get_idml_spreads( idml, format = "list", names_to = "Spread", ..., error_call = caller_env() )
idml |
A |
format |
"list", "xml_document", or "data.frame". If "list", contents
are converted with |
names_to |
By default, |
... |
Arguments passed on to
|
error_call |
The execution environment of a currently
running function, e.g. |
Is the object a list of XML document objects?
is_list_of_xml_documents(x)
is_list_of_xml_documents(x)
idml
objectread_idml()
takes a file path for an idml
file and returns an idml
object: a list containing a file name, file path, and the contents of the
file as a list of xml_document
objects and character vectors (for the
MIMETYPE file only).
read_idml(file, ..., exdir = tempdir())
read_idml(file, ..., exdir = tempdir())
file |
Path to a file ending in a |
... |
Additional parameters passed to |
exdir |
Directory to extract files to when using |
A idml
class object.