Skip to content

Commit

Permalink
Enabled HTML in markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
AJ-Ianozi committed Aug 24, 2024
1 parent dcab8d1 commit 512f8d6
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 9 deletions.
2 changes: 1 addition & 1 deletion alire.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "yass"
description = "Static website generator"
version = "3.1.0-dev"
version = "3.1.0"

authors = ["AJ Ianozi"]
maintainers = ["AJ Ianozi <[email protected]>"]
Expand Down
10 changes: 10 additions & 0 deletions docs/user/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@
-- detailslink: 0.3
-- detailslink: 0.2
-- detailslink: 0.1
## <a name="3.1"></a>[3.1] - 2024-08-83
### Added
- Alire support
- Includes HTML by default

### Changed
- Updated README.md
- Updated contributing guide
- Website itself now at yass.website

## <a name="3.0"></a>[3.0] - 2021-10-29

### Added
Expand Down
2 changes: 2 additions & 0 deletions docs/user/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ Possible settings for project:
* EnableSitemap: Did the program should create sitemap when creating the site.
Possible values are true or false (case-insensitive). Default value is
`true` (create sitemap).
* HTMLEnabled: Enables HTML that is embedded in the markdown. Default value is
`true`
* AtomFeedSource: Source which will be used for creating Atom feed of the
site. Possible values are: `none`: don't create Atom feed, `tags`: create
Atom entries from proper tags in .md files, `[filename]`: the path (related to
Expand Down
1 change: 1 addition & 0 deletions docs/user/site.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ ServerEnabled = true
BaseURL = https://yet-another-static-site-generator.github.io/docs-dev
AtomFeedSource = none
SitemapEnabled = false
HTMLEnabled = true
# Site tags
Name = Yet Another Static Site (Generator) Documentation
23 changes: 22 additions & 1 deletion src/config.adb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- Copyright 2019-2021 Bartek thindil Jasicki
-- Copyright 2019-2021 Bartek thindil Jasicki & 2022-2024 A.J. Ianozi
--
-- This file is part of YASS.
--
Expand Down Expand Up @@ -98,6 +98,11 @@ package body Config is
Item =>
"# Should the program create sitemap when creating the site. Possible values are true or false (case-insensitive).");
Put_Line(File => Config_File, Item => "SitemapEnabled = true");
Put_Line
(File => Config_File,
Item =>
"# Should program convert HTML in markdown documents to actual HTML. Possible values are true or false (case-insensitive).");
Put_Line(File => Config_File, Item => "HTMLEnabled = true");
Put_Line
(File => Config_File,
Item =>
Expand Down Expand Up @@ -279,6 +284,12 @@ package body Config is
(if To_Lower(Item => To_String(Source => Value)) = "true" then
True
else False);
elsif Field_Name =
To_Unbounded_String(Source => "HTMLEnabled") then
Yass_Config.HTML_Enabled :=
(if To_Lower(Item => To_String(Source => Value)) = "true" then
True
else False);
elsif Field_Name =
To_Unbounded_String(Source => "AtomFeedSource") then
if Value in To_Unbounded_String(Source => "none") |
Expand Down Expand Up @@ -521,6 +532,16 @@ package body Config is
else
Put_Line(File => Config_File, Item => "SitemapEnabled = false");
end if;
Put
(Item =>
"Do you want to HTML embedded in your markdown to be converted? (default - yes): ");
Answer := To_Unbounded_String(Source => Get_Line);
if Answer in To_Unbounded_String(Source => "yes") |
To_Unbounded_String(Source => "y") | Null_Unbounded_String then
Put_Line(File => Config_File, Item => "HTMLEnabled = true");
else
Put_Line(File => Config_File, Item => "HTMLEnabled = false");
end if;
Put
(Item =>
"Do you want to set more technical options (like configuring build-in web server)? (default - no): ");
Expand Down
3 changes: 2 additions & 1 deletion src/config.ads
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- Copyright 2019-2021 Bartek thindil Jasicki
-- Copyright 2019-2021 Bartek thindil Jasicki & 2022-2024 A.J. Ianozi
--
-- This file is part of YASS.
--
Expand Down Expand Up @@ -87,6 +87,7 @@ package Config is
Base_Url: Unbounded_String :=
To_Unbounded_String(Source => "http://localhost:8888");
Sitemap_Enabled: Boolean := True;
HTML_Enabled: Boolean := True;
Atom_Feed_Source: Unbounded_String :=
To_Unbounded_String(Source => "none");
Site_Name: Unbounded_String := To_Unbounded_String(Source => "New Site");
Expand Down
7 changes: 5 additions & 2 deletions src/pages.adb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- Copyright 2019-2021 Bartek thindil Jasicki & 2022 A.J. Ianozi
-- Copyright 2019-2021 Bartek thindil Jasicki & 2022-2024 A.J. Ianozi
--
-- This file is part of YASS.
--
Expand Down Expand Up @@ -83,6 +83,8 @@ package body Pages is
Import => True,
Convention => C,
External_Name => "cmark_markdown_to_html";
Markdown_Options : constant int :=
(if Yass_Config.HTML_Enabled then 16#20000# else 0);
-- Insert selected list of tags Tags_List to templates
procedure Insert_Tags(Tags_List: Tags_Container.Map) is
use AWS.Templates.Utils;
Expand Down Expand Up @@ -304,7 +306,8 @@ package body Pages is
(Item =>
Cmark_Markdown_To_Html
(Text => New_String(Str => To_String(Source => Content)),
Len => Size_T(Length(Source => Content)), Options => 0)));
Len => Size_T(Length(Source => Content)),
Options => Markdown_Options)));
-- Load the program modules with 'pre' hook
Load_Modules
(State => "pre", Page_Tags => Page_Tags,
Expand Down
8 changes: 4 additions & 4 deletions src/yass.adb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- Copyright 2019-2021 Bartek thindil Jasicki
-- Copyright 2019-2021 Bartek thindil Jasicki & 2022-2024 A.J. Ianozi
--
-- This file is part of YASS.
--
Expand Down Expand Up @@ -39,8 +39,8 @@ with Sitemaps;
with Server; use Server;

procedure Yass is
Version: constant String := "3.1.0-dev";
Released : constant String := "2024-06-01";
Version: constant String := "3.1.0";
Released : constant String := "2024-08-23";
--## rule off GLOBAL_REFERENCES
Work_Directory: Unbounded_String := Null_Unbounded_String;
--## rule on GLOBAL_REFERENCES
Expand Down Expand Up @@ -518,6 +518,6 @@ exception
Close(File => Error_File);
Put_Line
(Item =>
"Oops, something bad happen and program crashed. Please, remember what you done before crash and report this problem at https://www.laeran.pl/repositories/yass and attach (if possible) file 'error.log' (should be in this same directory).");
"Oops, something bad happen and program crashed. Please, remember what you done before crash and report this problem at https://github.com/yet-another-static-site-generator/yass and attach (if possible) file 'error.log' (should be in this same directory).");
end Save_Exception_Info_Block;
end Yass;

0 comments on commit 512f8d6

Please sign in to comment.