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.

74 lines
1.9 KiB

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