homebrew-core/Formula/md4c.rb

55 lines
1.7 KiB
Ruby

class Md4c < Formula
desc "C Markdown parser. Fast. SAX-like interface"
homepage "https://github.com/mity/md4c"
url "https://github.com/mity/md4c/archive/release-0.4.8.tar.gz"
sha256 "4a457df853425b6bb6e3457aa1d1a13bccec587a04c38c622b1013a0da41439f"
license "MIT"
bottle do
sha256 cellar: :any, big_sur: "8b4ae9a5232e84db3d0ab6793a8dd5bd56071fb32832fd94d16fa8162ec08a16"
sha256 cellar: :any, catalina: "8368b905e33301b5019e8520f7d010e3a57f74855ebd5cbbbf87aa1d8ded50a7"
sha256 cellar: :any, mojave: "ad888318dd048fc87594ff6a67321b9f9711bafb835f121f46f8f3e31de1931a"
end
depends_on "cmake" => :build
def install
system "cmake", ".", *std_cmake_args
system "make", "install"
end
test do
# test md2html
(testpath/"test_md.md").write <<~EOS
# Title
some text
EOS
system bin/"md2html", "./test_md.md"
# test libmd4c
(testpath/"test_program.c").write <<~EOS
#include <stddef.h>
#include <md4c.h>
MD_CHAR* text = "# Title\\nsome text";
int test_block(MD_BLOCKTYPE type, void* detail, void* data) { return 0; }
int test_span(MD_SPANTYPE type, void* detail, void* data) { return 0; }
int test_text(MD_TEXTTYPE type, const MD_CHAR* text, MD_SIZE size, void* userdata) { return 0; }
int main() {
MD_PARSER parser = {
.enter_block = test_block,
.leave_block = test_block,
.enter_span = test_span,
.leave_span = test_span,
.text = test_text
};
int result = md_parse(text, sizeof(text), &parser, NULL);
return result;
}
EOS
system ENV.cc, "test_program.c", "-L#{lib}", "-lmd4c", "-o", "test_program"
system "./test_program"
end
end