< prev index next >

make/common/ProcessMarkdown.gmk

Print this page




  48     ))
  49   else
  50     $1_$2_PANDOC_INPUT := $$($1_$2_INPUT_FILE)
  51   endif
  52 
  53   ifneq ($$($1_POST_PROCESS), )
  54     $1_$2_PANDOC_OUTPUT := $$(SUPPORT_OUTPUTDIR)/markdown/$$($1_$2_MARKER)_post.tmp
  55   else
  56     $1_$2_PANDOC_OUTPUT := $$($1_$2_OUTPUT_FILE)
  57   endif
  58 
  59   ifneq ($$($1_CSS), )
  60     ifneq ($$(findstring http:/, $$($1_CSS)), )
  61       $1_$2_CSS_OPTION := --css '$$($1_CSS)'
  62     else
  63       $1_$2_CSS := $$(strip $$(call RelativePath, $$($1_CSS), $$($1_$2_TARGET_DIR)))
  64       $1_$2_CSS_OPTION := --css '$$($1_$2_CSS)'
  65     endif
  66   endif
  67 
  68   # This does not need to be included in VARDEPS since it's from the actual
  69   # source file. Only run the shell if the recipe gets executed below.
  70   $1_$2_OPTIONS_FROM_SRC = \
  71       $$(shell $$(GREP) _pandoc-options_: $3/$2 | $$(CUT) -d : -f 2-)
  72 
  73   ifneq ($$($1_FILTER), )
  74     $1_$2_OPTIONS := --filter $$($1_FILTER)
  75   endif
  76 
  77   $1_$2_VARDEPS := $$($1_OPTIONS) $$($1_$2_OPTIONS) $$($1_CSS) \
  78       $$($1_REPLACEMENTS) $$($1_POST_PROCESS)
  79   $1_$2_VARDEPS_FILE := $$(call DependOnVariable, $1_$2_VARDEPS, \
  80       $$(SUPPORT_OUTPUTDIR)/markdown/$$($1_$2_MARKER).vardeps)
  81 
  82   $$($1_$2_PANDOC_OUTPUT): $$($1_$2_PANDOC_INPUT) $$($1_$2_VARDEPS_FILE) $$($1_EXTRA_DEPS)
  83         $$(call LogInfo, Converting $2 to $$($1_FORMAT))
  84         $$(call MakeDir, $$(SUPPORT_OUTPUTDIR)/markdown $$(dir $$($1_$2_PANDOC_OUTPUT)))
  85         $$(call ExecuteWithLog, $$(SUPPORT_OUTPUTDIR)/markdown/$$($1_$2_MARKER), \
  86             $$(PANDOC) $$($1_OPTIONS) -f $$(PANDOC_MARKDOWN_FLAG) \
  87             -t $$($1_FORMAT) --standalone \
  88             $$($1_$2_CSS_OPTION) $$($1_$2_OPTIONS_FROM_SRC) $$($1_$2_OPTIONS) \
  89             '$$($1_$2_PANDOC_INPUT)' -o '$$($1_$2_PANDOC_OUTPUT)')
  90         ifneq ($$(findstring $$(LOG_LEVEL), debug trace),)
  91           TOO_LONG_LINES=`$$(GREP) -E -e '^.{80}.+$$$$' $$<` || true ; \
  92           if [ "x$$$$TOO_LONG_LINES" != x ]; then \
  93             $$(ECHO) "Warning: Unsuitable markdown in $$<:" ; \
  94             $$(ECHO) "The following lines are longer than 80 characters:" ; \
  95             $$(GREP) -E -n -e '^.{80}.+$$$$' $$< || true ; \
  96           fi
  97         endif
  98 
  99   # If we have no post processing, PANDOC_OUTPUT is set to OUTPUT_FILE. Otherwise
 100   # PANDOC_OUTPUT is a temporary file, and we must now create the real OUTPUT_FILE.
 101   ifneq ($$($1_POST_PROCESS), )
 102     $$($1_$2_OUTPUT_FILE): $$($1_$2_PANDOC_OUTPUT)
 103         $$(call LogInfo, Post-processing markdown file $2)
 104         $$(call MakeDir, $$(SUPPORT_OUTPUTDIR)/markdown $$($1_$2_TARGET_DIR))
 105         $$(call ExecuteWithLog, $$(SUPPORT_OUTPUTDIR)/markdown/$$($1_$2_MARKER)_post, \
 106             $$($1_POST_PROCESS) < $$($1_$2_PANDOC_OUTPUT) > $$($1_$2_OUTPUT_FILE))
 107   endif
 108 
 109   $1 += $$($1_$2_OUTPUT_FILE)




  48     ))
  49   else
  50     $1_$2_PANDOC_INPUT := $$($1_$2_INPUT_FILE)
  51   endif
  52 
  53   ifneq ($$($1_POST_PROCESS), )
  54     $1_$2_PANDOC_OUTPUT := $$(SUPPORT_OUTPUTDIR)/markdown/$$($1_$2_MARKER)_post.tmp
  55   else
  56     $1_$2_PANDOC_OUTPUT := $$($1_$2_OUTPUT_FILE)
  57   endif
  58 
  59   ifneq ($$($1_CSS), )
  60     ifneq ($$(findstring http:/, $$($1_CSS)), )
  61       $1_$2_CSS_OPTION := --css '$$($1_CSS)'
  62     else
  63       $1_$2_CSS := $$(strip $$(call RelativePath, $$($1_CSS), $$($1_$2_TARGET_DIR)))
  64       $1_$2_CSS_OPTION := --css '$$($1_$2_CSS)'
  65     endif
  66   endif
  67 
  68   $1_$2_OPTIONS := $$(shell $$(GREP) _pandoc-options_: $3/$2 | $$(CUT) -d : -f 2-)



  69 
  70   ifneq ($$($1_FILTER), )
  71     $1_$2_OPTIONS += --filter $$($1_FILTER)
  72   endif
  73 
  74   $1_$2_VARDEPS := $$($1_OPTIONS) $$($1_$2_OPTIONS) $$($1_CSS) \
  75       $$($1_REPLACEMENTS) $$($1_POST_PROCESS)
  76   $1_$2_VARDEPS_FILE := $$(call DependOnVariable, $1_$2_VARDEPS, \
  77       $$(SUPPORT_OUTPUTDIR)/markdown/$$($1_$2_MARKER).vardeps)
  78 
  79   $$($1_$2_PANDOC_OUTPUT): $$($1_$2_PANDOC_INPUT) $$($1_$2_VARDEPS_FILE) $$($1_EXTRA_DEPS)
  80         $$(call LogInfo, Converting $2 to $$($1_FORMAT))
  81         $$(call MakeDir, $$(SUPPORT_OUTPUTDIR)/markdown $$(dir $$($1_$2_PANDOC_OUTPUT)))
  82         $$(call ExecuteWithLog, $$(SUPPORT_OUTPUTDIR)/markdown/$$($1_$2_MARKER), \
  83             $$(PANDOC) $$($1_OPTIONS) -f markdown -t $$($1_FORMAT) --standalone \
  84             $$($1_$2_CSS_OPTION) $$($1_$2_OPTIONS) '$$($1_$2_PANDOC_INPUT)' \
  85             -o '$$($1_$2_PANDOC_OUTPUT)')

  86         ifneq ($$(findstring $$(LOG_LEVEL), debug trace),)
  87           TOO_LONG_LINES=`$$(GREP) -E -e '^.{80}.+$$$$' $$<` || true ; \
  88           if [ "x$$$$TOO_LONG_LINES" != x ]; then \
  89             $$(ECHO) "Warning: Unsuitable markdown in $$<:" ; \
  90             $$(ECHO) "The following lines are longer than 80 characters:" ; \
  91             $$(GREP) -E -n -e '^.{80}.+$$$$' $$< || true ; \
  92           fi
  93         endif
  94 
  95   # If we have no post processing, PANDOC_OUTPUT is set to OUTPUT_FILE. Otherwise
  96   # PANDOC_OUTPUT is a temporary file, and we must now create the real OUTPUT_FILE.
  97   ifneq ($$($1_POST_PROCESS), )
  98     $$($1_$2_OUTPUT_FILE): $$($1_$2_PANDOC_OUTPUT)
  99         $$(call LogInfo, Post-processing markdown file $2)
 100         $$(call MakeDir, $$(SUPPORT_OUTPUTDIR)/markdown $$($1_$2_TARGET_DIR))
 101         $$(call ExecuteWithLog, $$(SUPPORT_OUTPUTDIR)/markdown/$$($1_$2_MARKER)_post, \
 102             $$($1_POST_PROCESS) < $$($1_$2_PANDOC_OUTPUT) > $$($1_$2_OUTPUT_FILE))
 103   endif
 104 
 105   $1 += $$($1_$2_OUTPUT_FILE)


< prev index next >