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.

75 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(ol), div.markdown :global(ul) {
  31. padding: 0.5em;
  32. margin: 0.25em 0;
  33. margin-left: 1ch;
  34. }
  35. div.markdown :global(ul) {
  36. list-style: none;
  37. }
  38. div.markdown :global(ol) {
  39. list-style: none;
  40. counter-reset: li;
  41. }
  42. div.markdown :global(ul) :global(li:before) {
  43. content: "\2022"; /* Add content: \2022 is the CSS Code/unicode for a bullet */
  44. color: #333; /* Change the color */
  45. font-weight: bold; /* If you want it to be bold */
  46. display: inline-block; /* Needed to add space between the bullet and the text */
  47. width: 1em; /* Also needed for space (tweak if needed) */
  48. margin-left: -1em; /* Also needed for space (tweak if needed) */
  49. }
  50. div.markdown :global(ol) :global(li) {
  51. counter-increment: li;
  52. }
  53. div.markdown :global(ol) :global(li:before) {
  54. content: counter(li)'.';
  55. color: #333; /* Change the color */
  56. font-weight: bold; /* If you want it to be bold */
  57. display: inline-block; /* Needed to add space between the bullet and the text */
  58. width: 1.75em; /* Also needed for space (tweak if needed) */
  59. margin-left: -1.5em; /* Also needed for space (tweak if needed) */
  60. padding-right: 0em;
  61. text-align: center;
  62. }
  63. </style>