{%- comment -%} * * MIT License * Copyright (c) 2020 Raghuveer S, Hiran Venugopalan * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * File: Content.html * Author Raghuveer S, Hiran Venugopalan * * This file contains the markup for the context menu thingy you see when you right * click on the post titles on the home page. * {%- endcomment -%}
{%- if site.preferences.wiki_style_link.enabled -%} {%- assign replaced_content = content -%} {%- assign tables = content | split:'' -%} {%- for item in tables -%} {%- assign m_end = item | split:'
' -%} {%- assign m_sl = m_end[0] | split:'![[' -%} {%- assign m_ee = m_sl[1] | split:'' -%} {%- assign m_sc = m_ee[1] | split:'' -%} {%- assign m_ec = m_sc[1] | split:']]' -%} {%- if m_ee[0] != nil -%} {%- if m_ec[0] != nil -%} {%- assign tableBlock = '' | append: m_end[0] | append: '
' -%} {%- assign table_replacing = '
' | append: m_ec[0] | append:'
' | append: m_ec[0] | append:'
' -%} {%- assign replaced_content = replaced_content | replace: tableBlock,table_replacing -%} {%- endif -%} {%- endif -%} {%- endfor -%} {%- assign image_basic = replaced_content | split:'![[' -%} {%- for item in image_basic -%} {%- assign m_end = item | split:']]' -%} {%- assign imgBlock = '![[' | append: m_end[0] | append: ']]' -%} {%- assign img_replacing = '
' | append: m_end[0] | append:'
' -%} {%- assign replaced_content = replaced_content | replace: imgBlock,img_replacing -%} {%- endfor -%} {%- assign blockquotes = replaced_content | split:'' -%} {%- assign m_text = m_end[0] | newline_to_br -%} {%- assign m_firsl_s = m_text | split:'

[!' -%} {%- assign m_firsl_e = m_firsl_s[1] | split:'
' -%} {%- assign m_firsl_sp = m_firsl_e[0] | split:']' -%} {%- assign rep_fl = '[!' | append: m_firsl_sp[0] | append: ']' | append: m_firsl_sp[1] | append: '
' -%} {%- assign m_text = m_text | replace: rep_fl,'' -%} {%- if m_end[0] != nil -%} {%- if m_firsl_sp[1] != nil -%} {%- assign callout_class_name = ' class="callout callout-' | append: m_firsl_sp[0] | append: '"' -%} {%- assign callout_title = '>

' | append: m_firsl_sp[1] | append: '
1 -%} {%- assign itemparts = item | split:']]' -%} {%- assign internal_link = itemparts[0] -%} {%- assign external_link = itemparts[0] | split:external_link_delimiter -%} {%- assign sidenote = itemparts[0] | split:sidenote_delimiter -%} {%- if external_link[1] == nil -%} {%- assign result_posts = site.posts | where: 'title',itemparts[0] -%} {%- assign result_posts = site.notes | where: 'slug',itemparts[0] -%} {%- assign result_pages = site.pages | where: 'title',itemparts[0] -%} {%- assign internal_links = internal_links | append: link_joiner_delimiter | append: internal_link -%} {%- assign internal_urls = internal_urls | append: link_joiner_delimiter | append: result_posts[0].url | append: result_pages[0].url -%} {%- else -%} {%- assign external_links = external_links | append: link_joiner_delimiter | append: external_link[0] -%} {%- assign external_urls = external_urls | append: link_joiner_delimiter | append: external_link[1] -%} {%- endif -%} {%- endif -%} {%- endfor -%} {%- assign internal_url_array = internal_urls | split:link_joiner_delimiter -%} {%- assign internal_link_array = internal_links | split:link_joiner_delimiter -%} {%- assign external_url_array = external_urls | split:link_joiner_delimiter -%} {%- assign external_link_array = external_links | split:link_joiner_delimiter -%} {%- for title in internal_link_array -%} {%- assign url = internal_url_array[forloop.index0] -%} {%- if url == nil -%} {%- assign link_text = '' | append: title | append: ' ' | append: {{site.privatelinks.title}} | append: '
' | append: {{site.privatelinks.msg}} | append : '
' -%} {%- elsif url == empty -%} {%- assign link_text = '' | append: title | append: ' ' | append: {{site.privatelinks.title}} | append: '
' | append: {{site.privatelinks.msg}} | append : '
' -%} {%- else -%} {%- assign post = site.notes | where: 'title',title -%} {%- if post[0].title == nil -%} {%- assign post = site.posts | where: 'title',title -%} {%- endif -%} {%- assign excerpt = post[0].content | markdownify | strip_html | truncate: 200 | newline_to_br -%} {%- if site.preferences.pagepreview.enabled -%} {%- assign link_text = '' | append: title | append: '' | append: title | append: '
' | append: excerpt | remove: "[[" | remove: "]]" | append: '
' -%} {%- else -%} {%- assign link_text = '' | append: title | append: '' -%} {%- endif -%} {%- endif -%} {%- assign bracket_link = '[[' | append: title | append: ']]' -%} {%- assign replaced_content = replaced_content | replace: bracket_link,link_text -%} {%- endfor -%} {%- assign sideNoteCounter = 0 -%} {%- assign srsCounter = 0 -%} {%- for title in external_link_array -%} {%- assign url = external_url_array[forloop.index0] -%} {%- if url == "highlight" -%} {%- if site.preferences.highlighting.enabled -%} {%- assign color = '#DAEDFF' -%} {%- if site.preferences.highlighting.color != nil and site.preferences.highlighting.color != empty and site.preferences.highlighting.color != null -%} {%- assign color = '#' | append: site.preferences.highlighting.color -%} {%- endif -%} {%- assign link_text = '' | append: title | append: '' -%} {%- endif -%} {%- elsif url == "wrap" -%} {%- if site.preferences.wrapping.enabled -%} {%- assign link_text = '

' | append: title | append: '

' -%} {%- endif -%} {%- elsif url == "img" -%} {%- if site.preferences.wrapping.enabled -%} {%- assign link_text = '' -%} {%- endif -%} {%- elsif url == "lsn" or url == "rsn" or url == "lsn-transclude" or url == "rsn-transclude" or url == "lmn" or url == "rmn" or url == "lmn-transclude" or url == "rmn-transclude" -%} {%- assign toggleLabel = "" -%} {%- assign sideNoteNum = "" -%} {%- if url contains "lsn" -%} {%- assign noteType = "sn-left" -%} {%- assign sideNoteNum = "sidenote-number" -%} {%- elsif url contains "rsn" -%} {%- assign noteType = "sn-right" -%} {%- assign sideNoteNum = "sidenote-number" -%} {%- elsif url contains "lmn" -%} {%- assign noteType = "mn-left" -%} {%- assign toggleLabel = "⊕" -%} {%- elsif url contains "rmn" -%} {%- assign noteType = "mn-right" -%} {%- assign toggleLabel = "⊕" -%} {%- endif -%} {%- if url contains "transclude" -%} {%- if site.preferences.sidenotes.enabled -%} {%- assign post = site.posts | where: 'title',title -%} {%- assign excerpt = post[0].content | strip_html | truncate: 280 -%} {%- assign link_text = ' Transclusion
' | append: title | append: '
' | append: excerpt | append: '
' -%} {%- endif -%} {%- else -%} {%- if site.preferences.sidenotes.enabled -%} {%- assign link_text = '' | append: title | append: '' -%} {%- endif -%} {%- endif -%} {%- assign sideNoteCounter = sideNoteCounter | plus:1 -%} {%- elsif url == "srs" -%} {%- if site.preferences.flashcards.enabled -%} {%- assign link_text = 'Flashcard
' | append: title | append: '
' -%} {%- assign srsCounter = srsCounter | plus:1 -%} {%- endif -%} {%- else -%} {%- assign link_text = '' | append: title | append: '' -%} {%- endif -%} {%- assign bracket_link = '[[' | append: title | append: external_link_delimiter | append: url | append: ']]' -%} {%- assign replaced_content = replaced_content | replace: bracket_link,link_text -%} {%- endfor -%} {% include anchor_headings.html html=replaced_content anchorBody="#" beforeHeading=true anchorClass="autoAnchor" %} {%- else -%} {% include anchor_headings.html html=content anchorBody="#" %} {{content}} {%- endif -%}