Skip to contents

This function will perform the transformation on three node types:

Usage

fix_sandpaper_links(body, yml = list())

Arguments

body

an XML document

yml

the list of key/value pairs derived from the _config.yml file

Value

the body, invisibly

Details

  • image

  • link

  • html_node

The transformation will be to remove relative paths ("../") and replace Jekyll templating (e.g. " page.root " and " site.swc_pages " with either nothing or the link to software carpentry, respectively.

Note

This is absolutely NOT comprehensive and some links will fail to be converted. If this happens, please report an issue: https://github.com/carpentries/pegboard/issues/new/

Examples


loop <- fs::path(lesson_fragment(), "_episodes", "14-looping-data-sets.md")
e <- Episode$new(loop)
b <- e$body
pegboard:::make_link_table(e)$orig
#>  [1] "https://docs.python.org/3/library/glob.html#glob.glob"                                 
#>  [2] "https://docs.python.org/3/library/glob.html"                                           
#>  [3] "https://docs.python.org/3/library/glob.html"                                           
#>  [4] "https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.shape.html"
#>  [5] "https://docs.python.org/3/library/stdtypes.html#str.split"                             
#>  [6] "https://carpentries.org/assets/img/TheCarpentries.svg"                                 
#>  [7] "../no-workie.svg"                                                                      
#>  [8] "https://carpentries.org/assets/img/TheCarpentries.svg"                                 
#>  [9] "../no-workie.svg"                                                                      
#> [10] "{{ page.root }}/index.html"                                                            
#> [11] "{{ site.swc_pages }}/shell-novice"                                                     
#> [12] "{{ page.root }}{% link"                                                                
#> [13] "{{ page.root }}/no-workie.svg"                                                         
suppressWarnings(yml <- yaml::read_yaml(file.path(e$lesson, "_config.yml")))
fix_sandpaper_links(b, yml)
pegboard:::make_link_table(e)$orig
#>  [1] "https://docs.python.org/3/library/glob.html#glob.glob"                                 
#>  [2] "https://docs.python.org/3/library/glob.html"                                           
#>  [3] "https://docs.python.org/3/library/glob.html"                                           
#>  [4] "https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.shape.html"
#>  [5] "https://docs.python.org/3/library/stdtypes.html#str.split"                             
#>  [6] "https://carpentries.org/assets/img/TheCarpentries.svg"                                 
#>  [7] "no-workie.svg"                                                                         
#>  [8] "https://carpentries.org/assets/img/TheCarpentries.svg"                                 
#>  [9] "no-workie.svg"                                                                         
#> [10] "index.html"                                                                            
#> [11] "https://swcarpentry.github.io/shell-novice"                                            
#> [12] "index.md"                                                                              
#> [13] "no-workie.svg"