Skip to content
This repository was archived by the owner on Aug 10, 2022. It is now read-only.

Commit 20838c7

Browse files
Merge pull request #10 from brminnick/Exclude-Code-Blocks
Exclude Markdown Code Blocks + Markdown Code Snippets
2 parents 5bd3f1d + d5d7269 commit 20838c7

10 files changed

Lines changed: 48 additions & 10 deletions
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp3.1</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<ProjectReference Include="..\GitHubReadmeWebTrends.Functions\GitHubReadmeWebTrends.Functions.csproj" />
10+
</ItemGroup>
11+
<ItemGroup>
12+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.8" />
13+
</ItemGroup>
14+
</Project>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using Microsoft.Extensions.Logging;
2+
3+
namespace GitHubReadmeWebTrends.Console
4+
{
5+
class Program
6+
{
7+
readonly static ILogger _log = LoggerFactory.Create(builder => builder.AddConsole()).CreateLogger(nameof(Console));
8+
9+
static void Main(string[] args)
10+
{
11+
12+
}
13+
}
14+
}

GitHubReadmeWebTrends.Functions/Functions/GetAdvocatesForPowerBIDashboard.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace GitHubReadmeWebTrends.Functions
1212
{
13-
class GetAdvocatesForPowerBIDashboard
13+
public class GetAdvocatesForPowerBIDashboard
1414
{
1515
readonly YamlService _yamlService;
1616
readonly CloudAdvocateService _cloudAdvocateService;

GitHubReadmeWebTrends.Functions/Functions/GetAdvocatesFunction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace GitHubReadmeWebTrends.Functions
1111
{
12-
class GetAdvocatesFunction
12+
public class GetAdvocatesFunction
1313
{
1414
const string _runOncePerMonth = "0 0 0 5 * *";
1515

GitHubReadmeWebTrends.Functions/Functions/GetGitHubReposFunction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace GitHubReadmeWebTrends.Functions
77
{
8-
class GetGitHubReposFunction
8+
public class GetGitHubReposFunction
99
{
1010
readonly GitHubGraphQLApiService _gitHubGraphQLApiService;
1111

GitHubReadmeWebTrends.Functions/Functions/GetReadmeFunction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace GitHubReadmeWebTrends.Functions
1111
{
12-
class GetReadmeFunction
12+
public class GetReadmeFunction
1313
{
1414
const string _runEveryHour = "0 0 * * * *";
1515

GitHubReadmeWebTrends.Functions/Functions/OpenPullRequestFunction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace GitHubReadmeWebTrends.Functions
1010
{
11-
class OpenPullRequestFunction
11+
public class OpenPullRequestFunction
1212
{
1313
readonly static string _backupEmailAddress = Environment.GetEnvironmentVariable("BackupEmailAddress") ?? string.Empty;
1414

GitHubReadmeWebTrends.Functions/Functions/VerifyWebTrendsFunction.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
namespace GitHubReadmeWebTrends.Functions
1212
{
1313
//Inspired by https://github.com/spboyer/ca-readme-tracking-links-action/
14-
static class VerifyWebTrendsFunction
14+
public static class VerifyWebTrendsFunction
1515
{
1616
const string _webTrendsQueryKey = "WT.mc_id";
1717

@@ -23,7 +23,8 @@ static class VerifyWebTrendsFunction
2323
"azure.com"
2424
};
2525

26-
static readonly Regex _urlRegex = new Regex(@"(((http|ftp|https):\/\/)+[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&amp;:\/~\+#]*[\w\-\@?^=%&amp;\/~\+#])?)");
26+
//https://stackoverflow.com/a/64286141/5953643
27+
static readonly Regex _urlRegex = new Regex(@"(?<!`)(`(?:`{2})?)(?:(?!\1).)*?\1|((?:ht|f)tps?:\/\/[\w-]+(?>\.[\w-]+)+(?:[\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?)");
2728
static readonly Regex _localeRegex = new Regex("^/\\w{2}-\\w{2}");
2829

2930
[FunctionName(nameof(VerifyWebTrendsFunction))]
@@ -34,7 +35,10 @@ public static void Run([QueueTrigger(QueueConstants.VerifyWebTrendsQueue)] (Repo
3435

3536
var (repository, gitHubUser) = data;
3637

37-
var updatedReadme = _urlRegex.Replace(repository.ReadmeText, x => AppendTrackingInfo(x.Groups[0].Value, repository.Name.Replace(".", "").Replace("-", "").ToLower(), "github", gitHubUser.MicrosoftAlias));
38+
var updatedReadme = _urlRegex.Replace(repository.ReadmeText,
39+
x => x.Groups[2].Success
40+
? UpdateUrl(x.Groups[0].Value, repository.Name.Replace(".", "").Replace("-", "").ToLower(), "github", gitHubUser.MicrosoftAlias)
41+
: x.Value);
3842

3943
if (!updatedReadme.Equals(repository.ReadmeText))
4044
{
@@ -45,7 +49,7 @@ public static void Run([QueueTrigger(QueueConstants.VerifyWebTrendsQueue)] (Repo
4549
log.LogInformation($"{nameof(VerifyWebTrendsFunction)} Completed");
4650
}
4751

48-
static string AppendTrackingInfo(in string link, in string eventName, in string channel, in string alias)
52+
static string UpdateUrl(in string link, in string eventName, in string channel, in string alias)
4953
{
5054
foreach (var domain in _microsoftDomainsList)
5155
{

GitHubReadmeWebTrends.Functions/Models/CloudAdvocatePowerBIModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace GitHubReadmeWebTrends.Functions
44
{
5-
class CloudAdvocatePowerBIModel
5+
public class CloudAdvocatePowerBIModel
66
{
77
public CloudAdvocatePowerBIModel(string name, string alias, Uri gitHub, Uri twitter, Uri linkedIn)
88
{

GitHubReadmeWebTrends.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GitHubReadmeWebTrends.Commo
88
EndProject
99
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GitHubReadmeWebTrends.Website", "GitHubReadmeWebTrends.Website\GitHubReadmeWebTrends.Website.csproj", "{67710356-35FB-48E8-BF21-073F2796589F}"
1010
EndProject
11+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHubReadmeWebTrends.Console", "GitHubReadmeWebTrends.Console\GitHubReadmeWebTrends.Console.csproj", "{0FCD9913-E1D5-4843-B258-E2FAE2C4E9B2}"
12+
EndProject
1113
Global
1214
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1315
Debug|Any CPU = Debug|Any CPU
@@ -26,6 +28,10 @@ Global
2628
{67710356-35FB-48E8-BF21-073F2796589F}.Debug|Any CPU.Build.0 = Debug|Any CPU
2729
{67710356-35FB-48E8-BF21-073F2796589F}.Release|Any CPU.ActiveCfg = Release|Any CPU
2830
{67710356-35FB-48E8-BF21-073F2796589F}.Release|Any CPU.Build.0 = Release|Any CPU
31+
{0FCD9913-E1D5-4843-B258-E2FAE2C4E9B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
32+
{0FCD9913-E1D5-4843-B258-E2FAE2C4E9B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
33+
{0FCD9913-E1D5-4843-B258-E2FAE2C4E9B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
34+
{0FCD9913-E1D5-4843-B258-E2FAE2C4E9B2}.Release|Any CPU.Build.0 = Release|Any CPU
2935
EndGlobalSection
3036
GlobalSection(SolutionProperties) = preSolution
3137
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)