Skip to content

Commit

Permalink
markdown (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickthecook committed Mar 15, 2024
1 parent cf5973b commit 2668267
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions app/javascript/controllers/markdown_text_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ export default class extends Controller {

updatedValueChanged() {
const markdownText = this.element.innerText || ""
const html = marked.parse(markdownText)
this.element.innerHTML = html
this.element.querySelectorAll("pre").forEach((block) => {
hljs.highlightElement(block)
})
const html = marked(markdownText, {breaks: true})
// this.element.innerHTML = html
// this.element.querySelectorAll("pre").forEach((block) => {
// hljs.highlightElement(block)
// })
}
}
2 changes: 1 addition & 1 deletion app/services/message_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def append(str)
when " "
ret += @in_code_block ? " " : " "
when "\n"
ret += "<br><br>"
ret += "<br>"
else
ret += CGI.escapeHTML(char)
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/conversations/_conversation_list.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div id="conversations" class="p-5 w-64 h-screen bg-secondary-300 dark:bg-secondary-900 text-secondary-700 dark:text-secondary-100">
<div class="container flex flex-col h-full">
<div class="pb-2 w-full font-mono text-2xl font-bold text-center"><%= link_to "ARCHYVE", root_path, class: "text-primary-800 dark:text-primary-300" %></div>
<%= button_to "New conversation", conversations_path, class: "rounded-lg py-1 px-3 my-2 text-center text-primary-200 dark:text-primary-950 block font-medium bg-primary-800 dark:bg-primary-300" %>
<%= button_to "New conversation", conversations_path, class: "rounded-lg py-1 px-3 my-2 text-center text-primary-200 dark:text-primary-950 block font-medium bg-primary-800 dark:bg-primary-300", target: :_top %>
<div class="flex-1">
<% conversations.each do |conversation| %>
<%= render "conversation_list_item", conversation: %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/messages/_message.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%= content_tag :div, id: dom_id(message), class: "flex justify-start items-start px-10 py-5 my-3 rounded-md shadow-lg bg-secondary-200 dark:bg-secondary-925" do %>
<div class="flex-1 whitespace-prewrap" data-controller="markdown-text">
<%= message.content.html_safe %>
<%= message.content %>
</div>
<p class="py-1 text-xs text-right text-muted"><%= author_name_for(message) %></p>
<p class="py-1 text-xs text-right text-muted"><%= time_ago_in_words(message.created_at) %> ago</p>
Expand Down

0 comments on commit 2668267

Please sign in to comment.