utils.xsl 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:xs="http://www.w3.org/2001/XMLSchema"
  4. xmlns:x="https://github.com/jelovirt/dita-ot-markdown"
  5. exclude-result-prefixes="xs x"
  6. version="2.0">
  7. <xsl:variable name="x:is-block-classes" as="xs:string*"
  8. select="
  9. (
  10. ' topic/body ',
  11. ' topic/bodydiv ',
  12. ' topic/shortdesc ',
  13. ' topic/abstract ',
  14. ' topic/title ',
  15. ' task/info ',
  16. ' topic/p ',
  17. ' topic/pre ',
  18. ' topic/note ',
  19. ' topic/fig ',
  20. ' topic/figgroup ',
  21. ' topic/dl ',
  22. ' topic/sl ',
  23. ' topic/ol ',
  24. ' topic/ul ',
  25. ' topic/li ',
  26. ' topic/sli ',
  27. ' topic/lines ',
  28. ' topic/itemgroup ',
  29. ' topic/section ',
  30. ' topic/sectiondiv ',
  31. ' topic/div ',
  32. ' topic/lq ',
  33. ' topic/table ',
  34. ' topic/entry ',
  35. ' topic/simpletable ',
  36. ' topic/stentry ',
  37. ' topic/example ',
  38. ' task/cmd ')"/>
  39. <xsl:function name="x:is-block" as="xs:boolean">
  40. <xsl:param name="element" as="node()"/>
  41. <xsl:variable name="class" select="string($element/@class)" as="xs:string"/>
  42. <xsl:sequence
  43. select="
  44. some $c in $x:is-block-classes
  45. satisfies contains($class, $c) or
  46. (contains($class, ' topic/image ') and $element/@placement = 'break')"
  47. />
  48. </xsl:function>
  49. </xsl:stylesheet>