Skip to content

Commit 5defc82

Browse files
committed
Add tests for BetterTogether content and template rendering
- Create a new spec for BetterTogether::Content::Template to test associations, validations, and methods. - Enhance BetterTogether::Page spec to include tests for template blocks and attributes in indexed JSON. - Implement request specs for markdown content block previews, covering various markdown features and error handling. - Add service specs for BetterTogether::MarkdownRendererService, ensuring proper rendering of markdown to HTML and plain text. - Introduce service specs for BetterTogether::TemplateRendererService, validating rendering for all locales and error handling. - Create view specs for markdown fields and block types, ensuring proper rendering and accessibility.
1 parent bcfb83c commit 5defc82

File tree

29 files changed

+3251
-40
lines changed

29 files changed

+3251
-40
lines changed

Gemfile.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ PATH
5555
rack-cors (>= 1.1.1, < 3.1.0)
5656
rack-mini-profiler
5757
rails (>= 7.2, < 8.1)
58+
redcarpet (~> 3.6)
5859
reform-rails (>= 0.2, < 0.4)
5960
rswag (>= 2.3.1, < 2.18.0)
6061
ruby-openai
@@ -609,6 +610,7 @@ GEM
609610
erb
610611
psych (>= 4.0.0)
611612
tsort
613+
redcarpet (3.6.1)
612614
redis (5.4.1)
613615
redis-client (>= 0.22.0)
614616
redis-client (0.26.1)

app/assets/stylesheets/better_together/content_blocks.scss

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,3 +241,197 @@
241241
margin-left: 5px;
242242
}
243243
}
244+
245+
// Markdown content styling - GitHub-flavored markdown styles
246+
.markdown-content {
247+
line-height: 1.6;
248+
color: #24292e;
249+
250+
// Headings
251+
h1, h2, h3, h4, h5, h6 {
252+
margin-top: 24px;
253+
margin-bottom: 16px;
254+
font-weight: 600;
255+
line-height: 1.25;
256+
border-bottom: 1px solid #eaecef;
257+
padding-bottom: 0.3em;
258+
}
259+
260+
h1 { font-size: 2em; }
261+
h2 { font-size: 1.5em; }
262+
h3 { font-size: 1.25em; }
263+
h4 { font-size: 1em; }
264+
h5 { font-size: 0.875em; }
265+
h6 { font-size: 0.85em; color: #6a737d; }
266+
267+
// Paragraphs and text
268+
p {
269+
margin-top: 0;
270+
margin-bottom: 16px;
271+
}
272+
273+
// Links
274+
a {
275+
color: #0366d6;
276+
text-decoration: none;
277+
278+
&:hover {
279+
text-decoration: underline;
280+
}
281+
}
282+
283+
// Lists
284+
ul, ol {
285+
padding-left: 2em;
286+
margin-top: 0;
287+
margin-bottom: 16px;
288+
}
289+
290+
li {
291+
margin-bottom: 0.25em;
292+
293+
> p {
294+
margin-top: 16px;
295+
}
296+
297+
+ li {
298+
margin-top: 0.25em;
299+
}
300+
}
301+
302+
// Blockquotes
303+
blockquote {
304+
padding: 0 1em;
305+
color: #6a737d;
306+
border-left: 0.25em solid #dfe2e5;
307+
margin: 0 0 16px 0;
308+
309+
> :first-child {
310+
margin-top: 0;
311+
}
312+
313+
> :last-child {
314+
margin-bottom: 0;
315+
}
316+
}
317+
318+
// Code blocks
319+
pre {
320+
padding: 16px;
321+
overflow: auto;
322+
font-size: 85%;
323+
line-height: 1.45;
324+
background-color: #f6f8fa;
325+
border-radius: 6px;
326+
margin-bottom: 16px;
327+
328+
code {
329+
display: inline;
330+
padding: 0;
331+
margin: 0;
332+
overflow: visible;
333+
line-height: inherit;
334+
word-wrap: normal;
335+
background-color: transparent;
336+
border: 0;
337+
}
338+
}
339+
340+
// Inline code
341+
code {
342+
padding: 0.2em 0.4em;
343+
margin: 0;
344+
font-size: 85%;
345+
background-color: rgba(27, 31, 35, 0.05);
346+
border-radius: 6px;
347+
font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
348+
}
349+
350+
// Tables
351+
table {
352+
border-spacing: 0;
353+
border-collapse: collapse;
354+
margin-top: 0;
355+
margin-bottom: 16px;
356+
width: 100%;
357+
overflow: auto;
358+
359+
th {
360+
font-weight: 600;
361+
padding: 6px 13px;
362+
border: 1px solid #dfe2e5;
363+
background-color: #f6f8fa;
364+
}
365+
366+
td {
367+
padding: 6px 13px;
368+
border: 1px solid #dfe2e5;
369+
}
370+
371+
tr {
372+
background-color: #fff;
373+
border-top: 1px solid #c6cbd1;
374+
375+
&:nth-child(2n) {
376+
background-color: #f6f8fa;
377+
}
378+
}
379+
}
380+
381+
// Horizontal rules
382+
hr {
383+
height: 0.25em;
384+
padding: 0;
385+
margin: 24px 0;
386+
background-color: #e1e4e8;
387+
border: 0;
388+
}
389+
390+
// Task lists
391+
.task-list-item {
392+
list-style-type: none;
393+
394+
input {
395+
margin: 0 0.2em 0.25em -1.6em;
396+
vertical-align: middle;
397+
}
398+
}
399+
400+
// Images
401+
img {
402+
max-width: 100%;
403+
box-sizing: content-box;
404+
background-color: #fff;
405+
border-radius: 6px;
406+
}
407+
408+
// Strikethrough
409+
del {
410+
text-decoration: line-through;
411+
}
412+
413+
// Superscript
414+
sup {
415+
vertical-align: super;
416+
font-size: smaller;
417+
}
418+
419+
// Highlight
420+
mark {
421+
background-color: #fff740;
422+
padding: 0.2em;
423+
}
424+
425+
// Footnotes
426+
.footnotes {
427+
margin-top: 32px;
428+
padding-top: 16px;
429+
border-top: 1px solid #e1e4e8;
430+
font-size: 0.9em;
431+
color: #6a737d;
432+
433+
ol {
434+
padding-left: 1.5em;
435+
}
436+
}
437+
}

0 commit comments

Comments
 (0)