The directory is not created even if the directory task is described in Rakefile.
In addition to describing (declaring) a directory task, that task I had to call it from somewhere to be executed.
directory "doc"
desc "create task"
task "create" do
cd "doc"
end
> rake -t create
** Invoke default (first_time)
** Invoke create (first_time)
** Execute create
cd doc
rake aborted!
Errno::ENOENT: No such file or directory @ dir_s_chdir - doc
I had to specify a directory task (named doc) as a prerequisite task for the create task.
directory "doc"
desc "create task"
task "create" => "doc" do
cd "doc"
end
> rake -t create
** Invoke create (first_time)
** Invoke doc (first_time)
** Execute doc
mkdir -p doc
** Execute create
cd doc
I was worried about 4 hours. However, I can't find much information about Rake.
With asciidoctor involved, a little snake foot information ↓
It's nice to be able to convert adoc files to html using asciidoctor Well, where I thought about publishing, I will upload it to Github Pages, Better yet, try using Hugo.
I was looking into it, but it seems that the directory where the images are placed Difficult to handle.
Put the content in contents/posts/api.adoc and the image directory is
I wanted something like contents/posts/images/image01.png,
For adoc, specify : imagesdir: ./images
.
In the reference, : image: image01.png []
.
$ asciidoctor -b html5 ./api.adoc
This should create contents/posts/api.html
.
When I try to check HTML with hugo service -D
,
When hugo is involved, from publish/posts/api.html
It is configured to reference publish/posts/api/images/image01.png
.
Where did the api directory come from ...?
Place the image directory in contents/posts/api/images/image01.png
If you replace it, there is no problem because it can be made consistent on the HTML display, but
Then, it is different from the path when HTML is output by executing the command of asciidoctor
(when previewing with marked2, it is troublesome because asciidoctor is used as the processor and preprocessor to output HTML).
So, hugo gave up and made HTML as it is with the behavior of the asciidoctor
command
Place the image file according to the generated image path ,.
When I tried using rake
to do something like that, I got stuck in a strange place.
~/bin/asciidoctor-marked2
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
# frozen_string_literal: true
marked_origin = ENV["MARKED_ORIGIN"] || Dir.pwd
rbenv = File.expand_path("~/.rbenv/bin/rbenv")
asciidoctor = "#{rbenv} exec asciidoctor"
cmd = "#{asciidoctor} -a skip-front-matter --safe-mode safe --base-dir #{marked_origin} --backend html5 -o - -"
system(cmd)
Write a Ruby script like this and give it execute permission.
If you specify it with Custom Processor like this, you can preview asciidoc with marked2.
With Hugo, I had to add Front Matter to the article, I was in trouble because it interfered with the processing of the asciidoctor command.
You can add -a skip-front-matter
to asciidoctor.
https://docs.asciidoctor.org/asciidoctor/latest/html-backend/skip-front-matter/
Recommended Posts