should_join function

should_join source

        def should_join(line):
            if line == "":
                return False
            if line is None:
                return False
            if line[0].isalpha():
                return True
            if line[0].startswith("["):
                return True
            if line[0].startswith("!"):
                return True
            return False

join_lines function

join_lines source

        def join_lines(article):
            lines = article.split("\n")
            line_number = 0
            while line_number + 1 < len(lines):
                line = lines[line_number]
                nextline = lines[line_number + 1]
                if should_join(line) and should_join(nextline):
                    lines[line_number] = f"{line} {nextline}"
                    lines.pop(line_number + 1)
                    line_number += 1

            return "\n".join(lines)

PublishDevToSourcePost class

PublishDevToSourcePost source

        class PublishDevToSourcePost(BaseModel):
            markata: Any = Field(None, exclude=True)
            canonical_url: Optional[str] = None

post_model function

post_model source

        def post_model(markata: "Markata") -> None:

post_render function

post_render source

        def post_render(markata: "Markata") -> None:
            for post in markata.iter_articles(description="saving source documents"):
                article = frontmatter.Post(
                    **{k: v for k, v in post.metadata.items() if k in DEV_TO_FRONTMATTER},

                article.content = join_lines(article.content)
                article.content = join_lines(article.content)

                if "canonical_url" not in article:
                    article["canonical_url"] = f"{markata.config.url}/{post.slug}/"

                if "published" not in article:
                    article["published"] = True

                if "cover_image" not in article:
                    article["cover_image"] = f"{markata.config.images_url}/{post.slug}.png"
                post.dev_to = article

save function

save source

        def save(markata: "Markata") -> None:
            output_dir = Path(str(markata.config.output_dir))
            with markata.console.status("Saving source documents...") as status:
                for post in markata.iter_articles(description="saving source documents"):
                    status.update(f"Saving {post['slug']}...")
                    with open(output_dir / Path(post["slug"]) / "", "w+") as f: