DEV Community

Jesse Chong
Jesse Chong

Posted on • Originally published at Medium

Cross-Post Project Update: Regex, Bug Fixes, and More Regex!



šŸŖž Reflecting on Last Weekā€™s Progress:When cross-posting from Medium to LinkedIn and DEV.to, I noticed several formatting issues: bold and italic text, as well as ordered and unordered lists, were not displaying correctly. Tags were also not posting accurately, and the URL linking back to the original article didnā€™t work as expected. After some adjustments, formatting is now accurate, and tags are correctly formatted for each platform.

šŸ“ˆ Project Update Overview:DEV.to uses Markdown syntax, while LinkedIn does not. LinkedIn also has a 1300-character limit and lacks consistent support for bold and italic formatting. I developed a helper function that formats posts for LinkedIn and DEV.to, adjusting based on the platformĀ input.

šŸ—ļø KeyĀ Updates:

  • Regex Improvements: Posts are now formatted correctly for LinkedIn andĀ DEV.to.
  • Tag Extraction from HTML: Tags are properly formatted for each platform.
  • Canonical URL Cleanup: Query parameters are removed, so the original article URL now works correctly. šŸ«Ø Challenges & Solutions šŸ’”Challenge 1: Bold, italics, and lists werenā€™t properly formatted for DEV.to and LinkedIn.

Solution:

  1. LinkedIn doesnā€™t support bold, italics, or bullet points, so these were replaced with plain text, with numbers used for bulletĀ points.
  2. After converting HTML to Markdown, ensured proper formatting (e.g., italics,Ā bold).
    Challenge 2: Tags from Medium werenā€™t cross-posting correctly.

  3. DEV.to limits tags to four, requiring lowercase alphanumeric tags in an arrayĀ format.

  4. LinkedIn allows hashtags to be embedded, but they must be camelCase (no spaces or dashes) and limited to 1300 characters.
    Solution:

Adjust tags to meet each platformā€™s requirements.

  1. For DEV.to: Remove non-alphanumeric characters, convert tags to lowercase, and limit to fourĀ tags.
  2. For LinkedIn: Remove any prefix hashtags, convert spaces or dashes to camelCase, and re-add theĀ #.
  3. Kept content within 1200 characters to allow room for title, URL, andĀ tags. Challenge 3: Mediumā€™s RSS feed sometimes includes unnecessary query parameters inĀ URLs.

Solution:

Extract the clean URL for cross-posting.

šŸŒŸ Reflection:Working with regex has been fascinating; itā€™s powerful and versatile for various use cases. Iā€™ve used it before in my Fresh Start project for translating directions, which showed me how effective it can be. That said, regex has limitations, so itā€™s essential to use it cautiously, depending on yourĀ needs.

šŸ”— Check Out the Repo: https://github.com/Jesse-Chong/Cross-post-server

Thank you for reading! Iā€™d love to hear your thoughts.

Originally published at Medium

Top comments (0)