You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
1.9 KiB

  1. <script lang="ts">
  2. import marked from "marked";
  3. import insane from "insane";
  4. export let source = "";
  5. let outputHtml: string;
  6. $: outputHtml = insane(marked(source, {smartypants: true}));
  7. </script>
  8. <div class="markdown">{@html outputHtml}</div>
  9. <style>
  10. div.markdown :global(p) {
  11. padding: 0;
  12. margin: 0.25em 0;
  13. }
  14. div.markdown :global(code) {
  15. background-color: #222;
  16. color: #1cf;
  17. }
  18. div.markdown :global(pre) > :global(code) {
  19. display: block;
  20. background-color: #222;
  21. color: #1cf;
  22. padding: 0.5em;
  23. }
  24. div.markdown :global(blockquote) {
  25. display: block;
  26. border-left: 4px solid #333;
  27. padding: 0.5em;
  28. margin: 0.5em 0;
  29. }
  30. div.markdown :global(img) {
  31. width: 100%;
  32. }
  33. div.markdown :global(ol), div.markdown :global(ul) {
  34. padding: 0.5em;
  35. margin: 0.25em 0;
  36. margin-left: 1ch;
  37. }
  38. div.markdown :global(ul) {
  39. list-style: none;
  40. }
  41. div.markdown :global(ol) {
  42. list-style: none;
  43. counter-reset: li;
  44. }
  45. div.markdown :global(ul) :global(li:before) {
  46. content: "\2022"; /* Add content: \2022 is the CSS Code/unicode for a bullet */
  47. color: #333; /* Change the color */
  48. font-weight: bold; /* If you want it to be bold */
  49. display: inline-block; /* Needed to add space between the bullet and the text */
  50. width: 1em; /* Also needed for space (tweak if needed) */
  51. margin-left: -1em; /* Also needed for space (tweak if needed) */
  52. }
  53. div.markdown :global(ol) :global(li) {
  54. counter-increment: li;
  55. }
  56. div.markdown :global(ol) :global(li:before) {
  57. content: counter(li)'.';
  58. color: #333; /* Change the color */
  59. font-weight: bold; /* If you want it to be bold */
  60. display: inline-block; /* Needed to add space between the bullet and the text */
  61. width: 1.75em; /* Also needed for space (tweak if needed) */
  62. margin-left: -1.5em; /* Also needed for space (tweak if needed) */
  63. padding-right: 0em;
  64. text-align: center;
  65. }
  66. </style>