Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. documentclass{article}
  2. usepackage{filecontentsdef}
  3. usepackage[enable-debug]{expl3}
  4. usepackage{xparse}
  5. ExplSyntaxOn
  6. debug_on:n{check-declarations,deprecation,check-expressions}
  7. % myscantokens
  8. NewDocumentCommand{myscantokens}{+m}
  9. {
  10. group_begin:
  11. tl_set:Nn l_tmpa_tl {#1}
  12. tl_put_right:Nx l_tmpb_tl %
  13. {
  14. tex_newlinechar:D = 13
  15. tex_everyeof:D = { exp_not:N }
  16. exp_not:N scantokens exp_after:wN { l_tmpa_tl }
  17. tex_newlinechar:D = 10 scan_stop:
  18. }
  19. l_tmpb_tl
  20. group_end:
  21. }
  22.  
  23. % mytlrescan
  24. tl_new:N l_tmpc_tl
  25. cs_generate_variant:Nn tl_set_rescan:Nnn { NnV }
  26. NewDocumentCommand{mytlrescan}{+m}
  27. {
  28. group_begin:
  29. tl_set:Nn l_tmpa_tl {#1}
  30. tl_set_rescan:NnV l_tmpb_tl { } l_tmpa_tl
  31. tl_put_right:Nx l_tmpc_tl %
  32. {
  33. tex_newlinechar:D = 13
  34. tex_everyeof:D = { exp_not:N }
  35. l_tmpb_tl
  36. tex_newlinechar:D = 10 scan_stop:
  37. }
  38. l_tmpc_tl
  39. group_end:
  40. }
  41. ExplSyntaxOff
  42. pagestyle{empty} % only for example
  43. begin{document}
  44. section{Default texttt{textbackslash filecontentsexec}}
  45.  
  46. begin{filecontentsdef*}{jobname.tmp}{macroA}
  47. Test environment with verb+filecontentsdef*+. verb+macroA+ its global.par
  48. begin{verbatim}
  49. A verbatim
  50. end{verbatim}
  51. end{filecontentsdef*}
  52. filecontentsexecmacroA
  53.  
  54. section{Using texttt{textbackslash scantokens}}
  55. myscantokens{macroA}
  56.  
  57. section{Using texttt{textbackslash tl_rescan:nn}}
  58. mytlrescan{macroA}
  59. end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement