Tare da kowace rana ta wucewa, abubuwan da ke ciki suna yaduwa a cikin dandamali daban-daban da matsakaici. Sabili da haka, buƙatar daidaitawa da tsara tsarin dandamali ya zama mafi mahimmanci fiye da kowane lokaci. Wannan shine inda ake canzawa daga HTML zuwa Markdown (MD) tsari yana fitowa a matsayin mafita mai mahimmanci. Sauƙaƙan Markdown da daidaituwa sun sa ya zama kyakkyawan zaɓi ga masu ƙirƙirar abun ciki, masu haɓakawa, da duk wanda ke neman ingantaccen hanyar gabatar da bayanansu. Ta hanyar canza HTML zuwa Markdown, ba wai kawai kuna tabbatar da iya karantawa da samun damar abun cikin ku ba amma har ma da buɗe yuwuwar rabawa mara kyau a cikin dandamali daban-daban ba tare da rikitattun salo na HTML ba.
A cikin wannan labarin, za mu shiga cikin cikakkun bayanai na canza HTML zuwa Markdown ta amfani da NET Cloud SDK.
- Cloud SDK don HTML zuwa Canjin Markdown
- HTML zuwa Markdown tare da C# .NET
- Maida HTML zuwa Markdown ta amfani da Umarnin CURL
Cloud SDK don HTML zuwa Canjin Markdown
Haɓaka ƙwarewar canjin abun ciki tare da Aspose.HTML Cloud SDK don NET, yana ba da mafita mara kyau don canza HTML zuwa tsarin Markdown (MD). Wannan SDK mai ƙarfi yana ba wa masu haɓakawa da masu amfani damar yin ƙoƙari ba tare da ɓata lokaci ba don kewaya rikitattun juzu’i na ‘html zuwa alama’ yayin da ke kiyaye amincin abun ciki da tsari.
Yanzu, don amfani da SDK, da fatan za a bincika ‘Aspose.HTML-Cloud’ a cikin manajan fakitin NuGet kuma danna maɓallin ‘Ƙara Kunshin’. Bugu da ƙari, da fatan za a ziyarci cloud dashboard kuma sami keɓaɓɓen takaddun shaidar abokin ciniki.
HTML zuwa Markdown tare da C# .NET
Bari mu nutse cikin cikakkun bayanai na HTML zuwa Juyin Markdown ta amfani da C# .NET.
// don cikakkun misalai, da fatan za a ziyarci https://github.com/aspose-html-cloud/aspose-html-cloud-dotnet
string clientSecret = "4d84d5f6584160cbd91dba1fe145db14";
string clientID = "bb959721-5780-4be6-be35-ff5c3a6aa4a2";
// tushen URL kirtani
const string SERVICE_API_HOST = "https://api.aspose.cloud";
// Ƙirƙiri misalin HtmlApi
HtmlApi htmlApi = new HtmlApi(clientID, clientSecret, SERVICE_API_HOST);
// sunan shigar da fayil HTML
String inputFileName = "source.html";
// sunan fitarwa fayil
String newFileName = "Converted.md";
try
{
// loda fayil ɗin daga rumbun gida
using (var file = System.IO.File.OpenRead(@"C:\Users\" + inputFileName))
{
// Ƙirƙiri misali StorageApi
var uploadFileRequest = new Aspose.Html.Cloud.Sdk.Api.StorageApi(clientID, clientSecret, SERVICE_API_HOST);
// loda fayil ɗin HTML zuwa ma'ajiyar Cloud
uploadFileRequest.UploadFile(file, "inputHTML.html");
}
// Fara HTML zuwa aikin jujjuya Markdown kuma ajiye fitarwa zuwa ma'ajiyar gajimare
AsposeResponse response = htmlApi.PutConvertDocumentToMarkdown(inputFileName,newFileName);
// buga saƙon nasara idan tuba ya yi nasara
if (response != null && response.Equals("OK"))
{
Console.WriteLine("Successfull completion of HTML to MD !");
}
catch (Exception ex)
{
Console.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);
}
Yanzu, bari mu bincika wasu cikakkun bayanai na snippet code na sama.
HtmlApi htmlApi = new HtmlApi(clientID, clientSecret);
Da farko, ƙirƙiri misalin ajin HtmlApi inda muke ƙaddamar da shaidar abokin ciniki azaman muhawara.
AsposeResponse response = htmlApi.PutConvertDocumentToMarkdown(inputFileName,newFileName);
Kira API don fara aikin canza HTML zuwa Markdown. Bayan nasarar aiki, ana adana sakamakon MD a cikin ma’ajin gajimare.
Maida HTML zuwa Markdown ta amfani da Umarnin CURL
Yi amfani da ƙarfin haɗin gwiwa na Aspose.HTML Cloud da cURL umarni don daidaita juzu’i daga tsarin HTML zuwa tsarin Markdown (MD). Ta hanyar ƙirƙira umarnin cURL wanda ke hulɗa tare da Aspose.HTML Cloud API, kuna ƙaddamar da sauyi mara kyau daga HTML zuwa Markdown. Wannan hanyar kuma tana ba ku damar riƙe tsarin abun ciki da tsarawa, tabbatar da cewa fayilolin da kuka canza suna kula da iya karantawa da ingancin gabatarwa.
Yanzu, tare da wannan hanyar, mataki na farko shine samar da alamar samun damar JWT ta aiwatar da umarni mai zuwa.
curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=bb959721-5780-4be6-be35-ff5c3a6aa4a2&client_secret=4d84d5f6584160cbd91dba1fe145db14" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"
Yanzu da muke da alamar samun damar JWT, da fatan za a aiwatar da umarni mai zuwa don loda shigar da HTML daga ma’ajiyar gajimare, canza shi zuwa tsarin Markdown (MD) kuma adana fayil ɗin sakamako akan tuƙi na gida.
curl -v "https://api.aspose.cloud/html/{inputHTML}/convert/md?outPath={resultantFile}&useGit=false" \
-X PUT \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}" \
-d {}
Sauya inputHTML
tare da sunan shigar da fayil ɗin HTML da aka riga akwai a cikin ma’ajiyar gajimare, ‘resultantFile’ tare da sunan sakamakon fayil ɗin Markdown akwai, da ‘accessToken’ tare da alamar samun damar JWT da aka samar a sama.
Kammalawa
A ƙarshe, jujjuyawar daga HTML zuwa tsarin Markdown (MD) alama ce mai mahimmancin mataki don haɓaka daidaituwar abun ciki, iya karantawa, da rabawa tsakanin dandamali daban-daban. Tare da hanyoyi guda biyu masu ƙarfi a hannunku, Aspose.HTML Cloud SDK don NET da kuma amfani da umarnin cURL, kuna da sassauci don zaɓar hanyar da ta dace da ƙwarewar fasaha da bukatunku. Duk da haka, leveraging da Aspose.HTML Cloud empowers ka kashe ‘html to markdown’ Abubuwan Taɗi tare da daidaici, adana abun ciki mutunci seamlessly.
Hanyoyin haɗi masu amfani
Labarai masu alaka
Muna ba da shawarar ziyartar shafukan yanar gizo masu zuwa: