cookbook.textile 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. ## CSS obscure rule: margin-top of
  2. <h1>
  3. affects parent's margin
  4. As of why they decided that this elements should behave like this it is still unclear for me; but at least we were able to find a rule that applies to collapsing margins: &quot;In simple terms, this definition indicates that when the vertical margins of two elements are touching, only the margin of the element with the largest margin value will be honored, while the margin of the element with the smaller margin value will be collapsed to zero Basically in our example on the original question, the biggest margin&#45;top is the one of the
  5. <h1>
  6. therefore taken and applied to the parent
  7. <div>
  8. . This rule is cancelled for: &#42; Floated elements &#42; Absolutely positioned elements &#42; Inline&#45;block elements &#42; Elements with overflow set to anything other than visible (They do not collapse margins with their children.) &#42; Cleared elements (They do not collapse their top margins with their parent block's bottom margin.) &#42; The root element That is the reason why overflow:hidden solved the issue.
  9. h2(#css-grids). CSS grids
  10. https://jsfiddle.net/zw9c7owa/ https://jsfiddle.net/zw9c7owa/3/ https://jsfiddle.net/zw9c7owa/4/ https://jsfiddle.net/zw9c7owa/6/ https://jsfiddle.net/zw9c7owa/7/ https://jsfiddle.net/zw9c7owa/8/ https://jsfiddle.net/zw9c7owa/12/ &#45;&gt; yeah! https://jsfiddle.net/zw9c7owa/13/ https://jsfiddle.net/zw9c7owa/14/ https://jsfiddle.net/zw9c7owa/15/ https://jsfiddle.net/zw9c7owa/16/ https://jsfiddle.net/zw9c7owa/17/
  11. Emulate CSS media print : https://uxdesign.cc/i&#45;totally&#45;forgot&#45;about&#45;print&#45;style&#45;sheets&#45;f1e6604cfd6
  12. h2(#processing-connections). processing connections
  13. https://research.lafkon.net/projects/dit/ https://research.lafkon.net/projects/lac2008/
  14. h3(#visualer-les-media-print-en-redimensionnant-la-page). visualer les media print en redimensionnant la page
  15. &#64;media screen and (max&#45;width: 699px) or media print { ... }
  16. h3(#john-resig-micro-template). John Resig Micro template
  17. Si jamais vous avez besoin de générer du HTML en javascript...
  18. https://johnresig.com/blog/javascript&#45;micro&#45;templating/
  19. h2(#césures). Césures
  20. http://gitlab.constantvzw.org/osp/tools.html5lib&#95;typogrify
  21. Les version récentes de webkit gèrent les césures
  22. interdire les césures
  23. bc. -webkit-hyphens: none;
  24. -moz-hyphens: none;
  25. hyphens: none;
  26. autoriser les césures
  27. bc. -webkit-hyphens: auto;
  28. Gérer les césures
  29. bc. -webkit-hyphenate-limit-before: 2; /* 2 caractères minimum en fin de ligne, donc en début de mot */
  30. -webkit-hyphenate-limit-after: 2; /* 3 caractères minimum en début de ligne, donc en fin de mot */
  31. -webkit-hyphenate-limit-lines: 4; /* 4 lignes consecutives max */
  32. NE PAS OUBLIER D'INSTALLER HYPHEN!
  33. sur arch
  34. @sudo pacman -S hyphen@ ou @yaourt -S hyphen@
  35. h2(#css-variables-in-page). CSS variables in &#64;page
  36. https://stackoverflow.com/questions/44735420/using&#45;custom&#45;properties&#45;with&#45;page&#45;rules
  37. h2(#convertir-tous-les-fichiers-html-en-markdown). Convertir tous les fichiers HTML en Markdown
  38. attention, vous allez perdre le contenu non&#45;sémantique (classes, attributs, etc.) mais ça peut justement être une manière de nettoyer son code
  39. for file in &#42;.html; do pandoc &#45;&#45;from html &#45;&#45;to markdown &#45;&#45;output &quot;<span class="math">{file%.*}.md&quot; &quot;</math>file&quot;; done
  40. h2(#html2print-readme). HTML2Print readme
  41. h3(#exemples-de-readme-visuels). exemples de readme visuels
  42. * http://organon.osp.kitchen/70
  43. * http://blog.lavillahermosa.com/brass&#45;%E2%86%92&#45;print&#45;tool&#45;v1/
  44. * http://design.lavillahermosa.com/works&#45;288&#45;le&#45;brass&#45;2014
  45. * http://blog.artsaucarre.be/artsnumeriques/2016/10/21/memory&#45;learning&#45;archives&#45;et&#45;bidouillages&#45;workshop&#45;au&#45;mundaneum&#45;24&#45;261016/
  46. * http://lorainefurter.net/readme/readme&#45;workflows.html
  47. * https://hpg.io/
  48. * https://youtu.be/eIgX6sPOqCY?t=2m40s
  49. <iframe width="560" height="315" src="https://youtu.be/eIgX6sPOqCY?t=2m40s" frameborder="0" allowfullscreen>
  50. </iframe>
  51. !http://hpg.io/img/multi_format.png! https://upload.wikimedia.org/wikipedia/commons/4/41/FACTSHEET&#45;EN.pdf https://research.lafkon.net/content/2.projects/6.wtf/99.wtf&#95;generator&#95;1&#95;00&#95;WEB.gif
  52. http://lorainefurter.net/readme/assets/readme/workflows/DigitalPublishingToolkit.png
  53. h3(#workflow-dun-numéro-de-médor). workflow d'un numéro de Médor
  54. * http://organon.osp.kitchen/90
  55. h3(#python-rss-to-html). python rss to html
  56. https://figureslibres.io/gogs/bachir/python&#45;rss2html
  57. <pre class="python">
  58. #!/usr/bin/python
  59. # -*- coding: utf-8 -*-
  60. import feedparser
  61. from bs4 import BeautifulSoup
  62. def main():
  63. # url du flux rss
  64. tpsreac_feed_url = &quot;https://tempsdereaction.wordpress.com/feed/&quot;
  65. # on aspire le flux rss avec feedparser
  66. tpsreac_feeds = feedparser.parse(tpsreac_feed_url)
  67. # base template du fichier html
  68. base = &quot;&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;/body&gt;&lt;/html&gt;&quot;
  69. # create dom for html file base
  70. base_dom = BeautifulSoup(base, 'html.parser')
  71. # page base template
  72. page_base = &quot;&lt;section class='page'&gt;&lt;/section&gt;&quot;
  73. # boucle sur les entrées racine du flux
  74. for key in tpsreac_feeds:
  75. print(key)
  76. # on boucle sur les entrées du flux rss
  77. for entrie in tpsreac_feeds['entries']:
  78. print('- - - - -',entrie['title'])
  79. # just display entrie keys
  80. for key in entrie:
  81. print(key)
  82. # entries.extend( feed[ &quot;items&quot; ] )
  83. # create page dom
  84. p_dom = BeautifulSoup(page_base, 'html.parser')
  85. # add content in page dom
  86. p_dom.section.append(entrie['summary'])
  87. # add newly created page dom to html dom
  88. base_dom.body.append(p_dom)
  89. # create main html file from filled base html dom
  90. with open(&quot;index.html&quot;, 'w') as fp:
  91. fp.write(base_dom.prettify(formatter=None))
  92. if __name__ == &quot;__main__&quot;:
  93. main()
  94. </pre>
  95. h3(#python-pandoc-and-template). python pandoc and template
  96. https://figureslibres.io/gogs/bachir/gitbook&#45;html2print
  97. <pre class="python">
  98. #!/usr/bin/python
  99. # -*- coding: utf-8 -*-
  100. from bs4 import BeautifulSoup
  101. import pypandoc
  102. def main():
  103. # create main html dom from template
  104. template_f = open(&quot;templates/main.tpl.html&quot;, &quot;r&quot;)
  105. template_html = template_f.read()
  106. template_dom = BeautifulSoup(template_html, 'html.parser')
  107. pdoc_args = ['--mathjax',
  108. '--smart']
  109. pdoc_filters = []
  110. output = pypandoc.convert_file(&quot;lechemin/de/monfichier.md&quot;,
  111. to='html5',
  112. format='markdown+header_attributes+link_attributes+bracketed_spans',
  113. extra_args=pdoc_args,
  114. filters=pdoc_filters)
  115. # outputfile=out_f)
  116. # print(&quot;output :\n&quot;+output)
  117. output_dom = BeautifulSoup(output, 'html.parser')
  118. template_dom.append(output_dom)
  119. # create main html file from filled template html dom
  120. html_f = 'monfichier.html'
  121. with open(html_f, 'w') as fp:
  122. fp.write(template_dom.prettify(formatter=None))
  123. if __name__ == &quot;__main__&quot;:
  124. main()
  125. </pre>
  126. h2(#ajuster-une-image). Ajuster une image
  127. voir https://developer.mozilla.org/en&#45;US/docs/Web/CSS/object&#45;fit et https://developer.mozilla.org/en&#45;US/docs/Web/CSS/object&#45;position
  128. h2(#css-regions). CSS regions
  129. h1(#flow-main). flow&#45;main {
  130. bc. -webkit-flow-into: flow-main;
  131. flow-into: flow-main;
  132. }
  133. .flow&#45;main { &#45;webkit&#45;flow&#45;from: flow&#45;main; flow&#45;from: flow&#45;main; }
  134. ex: https://jsfiddle.net/asmqaheq/